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
=== modified file 'nautilus_image_manipulator/ImageManipulations.py'
--- nautilus_image_manipulator/ImageManipulations.py 2012-05-05 08:04:46 +0000
+++ nautilus_image_manipulator/ImageManipulations.py 2012-12-31 23:46:24 +0000
@@ -1,17 +1,17 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2010-2012 Emilien Klein <emilien _AT_ klein _DOT_ st>3# Copyright (C) 2010-2012 Emilien Klein <emilien _AT_ klein _DOT_ st>
4# 4#
5# This program is free software: you can redistribute it and/or modify it 5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published 6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.7# by the Free Software Foundation.
8# 8#
9# This program is distributed in the hope that it will be useful, but 9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of 10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.12# PURPOSE. See the GNU General Public License for more details.
13# 13#
14# You should have received a copy of the GNU General Public License along 14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.15# with this program. If not, see <http://www.gnu.org/licenses/>.
16### END LICENSE16### END LICENSE
1717
@@ -22,7 +22,7 @@
22import Image22import Image
23import logging23import logging
24try:24try:
25 import pyexiv225 from gi.repository import GExiv2
26except ImportError:26except ImportError:
27 pass27 pass
2828
@@ -91,7 +91,7 @@
9191
92 def resize_one_image(self, fileName):92 def resize_one_image(self, fileName):
93 """Performs the resizing operation on one image.93 """Performs the resizing operation on one image.
94 94
95 The return value indicates if this resizing operation was successful.95 The return value indicates if this resizing operation was successful.
96 """96 """
97 logging.debug('resizing image: %s' % fileName)97 logging.debug('resizing image: %s' % fileName)
@@ -161,26 +161,18 @@
161 if not (skip or retry or cancel):161 if not (skip or retry or cancel):
162 try:162 try:
163 # Load EXIF data163 # Load EXIF data
164 exif = pyexiv2.ImageMetadata(fileName)164 exif = GExiv2.Metadata(fileName)
165 exif.read()
166 # Change EXIF image size to the new size165 # Change EXIF image size to the new size
167 exif["Exif.Photo.PixelXDimension"] = int(width)166 exif["Exif.Photo.PixelXDimension"] = str(int(width))
168 exif["Exif.Photo.PixelYDimension"] = int(height)167 exif["Exif.Photo.PixelYDimension"] = str(int(height))
169 # Copy the EXIF data to the new image168 # Copy the EXIF data to the new image
170 newExif = pyexiv2.ImageMetadata(newFileName)169 newExif = GExiv2.Metadata(newFileName)
171 newExif.read()170 for tag in exif.get_exif_tags():
172 exif.copy(newExif)171 newExif[tag] = exif[tag]
173 newExif.write()172 newExif.save_file()
174 except UnicodeDecodeError as e:
175 # Can happen when the filename contains non-ASCII characters
176 str = "Could not update exif data due to UnicodeDecodeError: %s" % e
177 str += "\nHint: The filename/path probably contains non-ASCII characters"
178 str += "\n%s" % fileName
179 str += "\n%s" % newFileName
180 logging.error(str)
181 except NameError:173 except NameError:
182 logging.info("pyexiv2 is not available, EXIF data won't " \174 logging.info(
183 "be copied over")175 "GExiv2 is not available, EXIF data won't be copied over")
184 return (skip, cancel, newFileName)176 return (skip, cancel, newFileName)
185177
186 def pack_images(self):178 def pack_images(self):

Subscribers

People subscribed via source and target branches