Merge lp:~robru/nautilus-image-manipulator/gexiv2 into lp:nautilus-image-manipulator

Proposed by Robert Bruce Park
Status: Merged
Merged at revision: 194
Proposed branch: lp:~robru/nautilus-image-manipulator/gexiv2
Merge into: lp:nautilus-image-manipulator
Diff against target: 84 lines (+20/-28)
1 file modified
nautilus_image_manipulator/ImageManipulations.py (+20/-28)
To merge this branch: bzr merge lp:~robru/nautilus-image-manipulator/gexiv2
Reviewer Review Type Date Requested Status
Emilien Klein Needs Information
Review via email: mp+141539@code.launchpad.net

Description of the change

This branch ports your application off of pyexiv2 and onto GExiv2. This offers you a number of advantages:

* GExiv2 has support for Unicode characters in the filenames, so this port allowed me to fix that bug where you couldn't copy EXIF data from/to files with Unicode characters in the name.

* GExiv2 has complete, effortless support for Python 3, which will make it easier to port your application to Python 3 should you choose to do so (pyexiv2 does not support Python 3 and is an obstacle to any Python 3 porting effort you might undertake). I highly recommend porting to Python 3 soon, because Python 2 is obsolete.

* GExiv2 and pyexiv2 are both wrappers around the exact same libexiv2 library, except that the pyexiv2 project is 5,000 lines of code, while GExiv2's python support is around 100 lines of code. This makes GExiv2 *much* simpler and easier to maintain.

To post a comment you must log in.
Revision history for this message
Emilien Klein (emilien-klein) wrote :

Thanks Robert for the merge proposal, I do agree that this is the right move.
However, while testing it, I'm having issues importing GExiv2 from gi.repository. I've installed libexiv2-dev as indicated on [0], but that package does not provide GObject Introspection.

There is Gexiv2 packages with GObject Introspection support at [1] but that isn't part [yet?] of the official Debian repo (or Ubuntu).

Question: how can I get this working properly? My development box is running Ubuntu 12.04.

[0] http://redmine.yorba.org/projects/gexiv2/wiki
[1] http://debian.dev-zero.nl/blog/archives/280

review: Needs Information
Revision history for this message
Robert Bruce Park (robru) wrote :

The package you need is called 'gir1.2-gexiv2-0.4'. It is not included in Ubuntu 12.04 unfortunately, and it only just barely made it into 12.10 in time.

I would recommend updating to 12.10 for a development box, if not 13.04 (I am already using 13.04 with great success). If you must stick with 12.04, you can compile gexiv2 from source quite easily, instructions are here:

http://redmine.yorba.org/projects/gexiv2/wiki

Revision history for this message
Emilien Klein (emilien-klein) wrote :

Just to keep you informed on the progress:
My dev box is running Debian Sid. Sid hasn't got the GI package yet (due to freeze), but that package was uploaded to experimental, unfortunately it seems like there is a bug [0] with that pacakge that prevents me from running the code (the dev-zero package or the ubuntu package work fine).

I'll merge your patch once I can also upload it to Debian. Not sure if you would be able to quickly see what's wrong with the package in Debian experimental?

[0] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697204

Revision history for this message
Emilien Klein (emilien-klein) wrote :

Previously mentionned Debian bug was fixed, I've merged your code and will prepare a new release in the coming days.
Thanks Robert for your contribution.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nautilus_image_manipulator/ImageManipulations.py'
2--- nautilus_image_manipulator/ImageManipulations.py 2012-05-05 08:04:46 +0000
3+++ nautilus_image_manipulator/ImageManipulations.py 2012-12-31 23:46:24 +0000
4@@ -1,17 +1,17 @@
5 # -*- coding: utf-8 -*-
6 ### BEGIN LICENSE
7 # Copyright (C) 2010-2012 Emilien Klein <emilien _AT_ klein _DOT_ st>
8-#
9-# This program is free software: you can redistribute it and/or modify it
10-# under the terms of the GNU General Public License version 3, as published
11+#
12+# This program is free software: you can redistribute it and/or modify it
13+# under the terms of the GNU General Public License version 3, as published
14 # by the Free Software Foundation.
15-#
16-# This program is distributed in the hope that it will be useful, but
17-# WITHOUT ANY WARRANTY; without even the implied warranties of
18-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
19+#
20+# This program is distributed in the hope that it will be useful, but
21+# WITHOUT ANY WARRANTY; without even the implied warranties of
22+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
23 # PURPOSE. See the GNU General Public License for more details.
24-#
25-# You should have received a copy of the GNU General Public License along
26+#
27+# You should have received a copy of the GNU General Public License along
28 # with this program. If not, see <http://www.gnu.org/licenses/>.
29 ### END LICENSE
30
31@@ -22,7 +22,7 @@
32 import Image
33 import logging
34 try:
35- import pyexiv2
36+ from gi.repository import GExiv2
37 except ImportError:
38 pass
39
40@@ -91,7 +91,7 @@
41
42 def resize_one_image(self, fileName):
43 """Performs the resizing operation on one image.
44-
45+
46 The return value indicates if this resizing operation was successful.
47 """
48 logging.debug('resizing image: %s' % fileName)
49@@ -161,26 +161,18 @@
50 if not (skip or retry or cancel):
51 try:
52 # Load EXIF data
53- exif = pyexiv2.ImageMetadata(fileName)
54- exif.read()
55+ exif = GExiv2.Metadata(fileName)
56 # Change EXIF image size to the new size
57- exif["Exif.Photo.PixelXDimension"] = int(width)
58- exif["Exif.Photo.PixelYDimension"] = int(height)
59+ exif["Exif.Photo.PixelXDimension"] = str(int(width))
60+ exif["Exif.Photo.PixelYDimension"] = str(int(height))
61 # Copy the EXIF data to the new image
62- newExif = pyexiv2.ImageMetadata(newFileName)
63- newExif.read()
64- exif.copy(newExif)
65- newExif.write()
66- except UnicodeDecodeError as e:
67- # Can happen when the filename contains non-ASCII characters
68- str = "Could not update exif data due to UnicodeDecodeError: %s" % e
69- str += "\nHint: The filename/path probably contains non-ASCII characters"
70- str += "\n%s" % fileName
71- str += "\n%s" % newFileName
72- logging.error(str)
73+ newExif = GExiv2.Metadata(newFileName)
74+ for tag in exif.get_exif_tags():
75+ newExif[tag] = exif[tag]
76+ newExif.save_file()
77 except NameError:
78- logging.info("pyexiv2 is not available, EXIF data won't " \
79- "be copied over")
80+ logging.info(
81+ "GExiv2 is not available, EXIF data won't be copied over")
82 return (skip, cancel, newFileName)
83
84 def pack_images(self):

Subscribers

People subscribed via source and target branches