django-versatileimagefield icon indicating copy to clipboard operation
django-versatileimagefield copied to clipboard

Add libopenjpeg-dev fix to docs (ZeroDivisionError: division by zero)

Open iraycd opened this issue 9 years ago • 7 comments

At datastructures/base.py#L77

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 avatar May 19 '16 10:05 iraycd

@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

theskumar avatar May 24 '16 12:05 theskumar

Yeah, I am using the latest Pillow==3.2.0

iraycd avatar May 24 '16 22:05 iraycd

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 avatar May 31 '16 00:05 respondcreate

@respondcreate Nope. This error has occurred with .JPG

It was for this image. http://siyora.com/media/products/BG39.jpg

iraycd avatar May 31 '16 13:05 iraycd

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?

respondcreate avatar May 31 '16 14:05 respondcreate

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

iraycd avatar May 31 '16 15:05 iraycd

Oh nice! Glad things got sorted, @iraycd . Should probably add a note about this to the docs...

respondcreate avatar May 31 '16 15:05 respondcreate