Note that there are some explanatory texts on larger screens.

plurals
  1. POCopying and Writing EXIF information from one image to another using pyexiv2
    primarykey
    data
    text
    <p>Am trying to copy EXIF information of a Image file to the resized version of the same image using pyexiv2. Searching for a solution i stumbled upon a post in <a href="https://stackoverflow.com/questions/400788/resize-image-in-python-without-losing-exif-data">Stack Overflow</a>. It looks like the api's used in the function is outdated and is not available in the latest version. Based on the latest document i created a function like this</p> <pre><code>def get_exif(file): """ Retrieves EXIF information from a image """ ret = {} metadata = pyexiv2.ImageMetadata(str(file)) metadata.read() info = metadata.exif_keys for key in info: data = metadata[key] ret[key] = data.raw_value return ret def write_exif(originFile, destinationFile, **kwargs): """ This function would write an exif information of an image file to another image file """ exifInformation = get_exif(originFile) metadata = pyexiv2.ImageMetadata(str(destinationFile)) for key, value in exifInformation.iteritems(): metadata[key] = value copyrightName = kwargs.get('copyright', None) if copyrightName != None: metadata['Exif.Image.Copyright'] = copyrightName try: metadata.write() except: return False else: return True </code></pre> <p>But this ends up in an error</p> <blockquote> <p>Python argument types in _ExifTag._setParentImage(_ExifTag, NoneType) did not match C++ signature: _setParentImage(exiv2wrapper::ExifTag {lvalue}, exiv2wrapper::Image {lvalue})</p> </blockquote> <p>I am now clueless on what went wrong. Could someone please help me out? Thanks</p> <h2>EDIT</h2> <p>Based on @unutbu 's suggestion I made change to data.raw_value in get_exif() method to data.value but still am facing the same issue. Am pasting more information regarding this error:</p> <pre><code>Python argument types in _ExifTag._setParentImage(_ExifTag, NoneType) did not match C++ signature: _setParentImage(exiv2wrapper::ExifTag {lvalue}, exiv2wrapper::Image {lvalue}) Request Method: POST Request URL: http://localhost:8000/accounts/photography/ Django Version: 1.3.1 Exception Type: ArgumentError Exception Value: Python argument types in _ExifTag._setParentImage(_ExifTag, NoneType) did not match C++ signature: _setParentImage(exiv2wrapper::ExifTag {lvalue}, exiv2wrapper::Image {lvalue}) Exception Location: /usr/lib64/python2.7/site-packages/pyexiv2/exif.py in _set_owner, line 107 **Traceback** /usr/local/lib/python2.7/site-packages/django/core/handlers/base.py in get_response response = callback(request, *callback_args, **callback_kwargs) ... /usr/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py in _wrapped_view return view_func(request, *args, **kwargs) ... /home/swaroop/public_html/xyz/xyz/apps/photography/views.py in accountsPhotoList write_exif(originFile=filePath, destinationFile=output) ... /home/swaroop/public_html/xyz/xyz/library/imageManipulation.py in write_exif metadata[key] = value ... /usr/lib64/python2.7/site-packages/pyexiv2/metadata.py in __setitem__ return getattr(self, '_set_%s_tag' % family)(key, tag_or_value) ... /usr/lib64/python2.7/site-packages/pyexiv2/metadata.py in _set_exif_tag tag._set_owner(self) ... /usr/lib64/python2.7/site-packages/pyexiv2/exif.py in _set_owner self._tag._setParentImage(metadata._image) ... Python Executable: /usr/bin/python2.7 Python Version: 2.7.2 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload