django-versatileimagefield
django-versatileimagefield copied to clipboard
Add libopenjpeg-dev fix to docs (ZeroDivisionError: division by zero)
File "/www/gkk-package/local/lib/python2.7/site-packages/django/forms/forms.py" in as_widget
593. return force_text(widget.render(name, self.value(), attrs=attrs))
File "/www/gkk-package/local/lib/python2.7/site-packages/versatileimagefield/widgets.py" in render
204. attrs
File "/www/gkk-package/local/lib/python2.7/site-packages/django/forms/widgets.py" in render
826. output.append(widget.render(name + '_%s' % i, widget_value, final_attrs))
File "/www/gkk-package/local/lib/python2.7/site-packages/versatileimagefield/widgets.py" in render
121. value
File "/www/gkk-package/local/lib/python2.7/site-packages/versatileimagefield/widgets.py" in image_preview
87. 'sized_url': value.thumbnail['300x300'],
File "/www/gkk-package/local/lib/python2.7/site-packages/versatileimagefield/datastructures/sizedimage.py" in __getitem__
116. height=height
File "/www/gkk-package/local/lib/python2.7/site-packages/versatileimagefield/datastructures/sizedimage.py" in create_resized_image
184. image, save_kwargs = self.preprocess(image, image_format)
File "/www/gkk-package/local/lib/python2.7/site-packages/versatileimagefield/datastructures/base.py" in preprocess
75. exif_datadict = image._getexif() # returns None if no EXIF data
File "/www/gkk-package/local/lib/python2.7/site-packages/PIL/JpegImagePlugin.py" in _getexif
391. return _getexif(self)
File "/www/gkk-package/local/lib/python2.7/site-packages/PIL/JpegImagePlugin.py" in _getexif
425. exif.update(info)
File "/www/gkk-package/local/lib/python2.7/site-packages/PIL/TiffImagePlugin.py" in __getitem__
354. self[tag] = handler(self, data, self.legacy_api) # check type
File "/www/gkk-package/local/lib/python2.7/site-packages/PIL/TiffImagePlugin.py" in load_rational
484. for num, denom in zip(vals[::2], vals[1::2]))
File "/www/gkk-package/local/lib/python2.7/site-packages/PIL/TiffImagePlugin.py" in <genexpr>
484. for num, denom in zip(vals[::2], vals[1::2]))
File "/www/gkk-package/local/lib/python2.7/site-packages/PIL/TiffImagePlugin.py" in <lambda>
482. combine = lambda a, b: (a, b) if legacy_api else a / b
Exception Type: ZeroDivisionError at /admin/product/product/2188/
Exception Value: division by zero
@iraycd Please confirm that you are facing the issue with latest version of PILLOW. This was a bug is PILLOW is resolved recently.
cc @respondcreate
Yeah, I am using the latest Pillow==3.2.0
Hey @iraycd !
It looks like problem is arising from trying to process an image that is in the TIFF file format. At present django-versatileimagefield only officially supports JPEG, GIF and PNG images. If you know how to get TIFFs working properly I'd be more than happy to merge in a PR!
@respondcreate Nope. This error has occurred with .JPG
It was for this image. http://siyora.com/media/products/BG39.jpg
Hey @iraycd –
I ran into a similar issue on an application I was working on and, after opening the file with photoshop and saving it as JPEG (with File > Save Optimized As), the issue went away. It turns out the offending image was saved with 'JPEG (old style)' compression (which Pillow was perceiving as TIFF) after being color corrected. Can you try doing something similar and see if the problem persists?
Yeah, this is the issue which I faced.
I have reinstalled Pillow again, which said *** OPENJPEG (JPEG2000) support not available
Solved it by installing libopenjpeg-dev
Oh nice! Glad things got sorted, @iraycd . Should probably add a note about this to the docs...