jdriscoll / django-imagekit

Automates image processing for Django models. Resize, process and cache multiple versions of your image files. Access newly created files with a standard API. Supports alternate storage schemes such as Amazon S3.

Clone this repository (size: 135.6 KB): HTTPS / SSH
$ hg clone http://hg.driscolldev.com/django-imagekit
follow

#23 Exception Type: IOError at /database/manufacturer/cpanel/product/new/ Exception Value: encoder error -2 when writing image file

Reported by Anonymous, created 6 months ago, last edited unknown.

There is an strange bug if uploading a too small image. But the error occurs only sometimes... Any ideas how to fix? Do you need my models, images_specs, image to reproduce?

Traceback:
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/contrib/auth/decorators.py" in __call__
  78.             return self.view_func(request, *args, **kwargs)
File "/Users/boerni/Projects/ldb/../ldb/database/views.py" in manufacturer_cpanel_product_new
  161.                 save_jcrop_image_2_model(product_image.original_image, MEDIA_ROOT_TMP+form.cleaned_data[field], product_new.get_image_name())
File "/Users/boerni/Projects/ldb/../ldb/utils/helper.py" in save_jcrop_image_2_model
  12.                      save=True)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/fields/files.py" in save
  100.             self.instance.save()
File "/Users/boerni/Projects/ldb/../ldb/database/models.py" in save
  225.         super(ProductImage, self).save()        
File "/Users/boerni/Projects/ldb/external/django/imagekit/models.py" in save
  145.         self._pre_cache()
File "/Users/boerni/Projects/ldb/external/django/imagekit/models.py" in _pre_cache
  110.                 prop._create()
File "/Users/boerni/Projects/ldb/external/django/imagekit/specs.py" in _create
  65.         content = ContentFile(self._get_imgfile().read())
File "/Users/boerni/Projects/ldb/external/django/imagekit/specs.py" in _get_imgfile
  50.                                   optimize=True)
File "/Users/boerni/Projects/ldb/external/django/imagekit/utils.py" in img_to_fobj
  7.     img.save(tmp, format, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/Image.py" in save
  1439.             save_handler(self, fp, filename)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/JpegImagePlugin.py" in _save
  471.     ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageFile.py" in _save
  501.                 raise IOError("encoder error %d when writing image file" % s)

Exception Type: IOError at /database/manufacturer/cpanel/product/new/
Exception Value: encoder error -2 when writing image file
Status: invalid Responsible: nobody Type: bug
Milestone: none Component: none Version: none

Attachments

No attachments added for this issue yet.

Comments and changes

#1

Justin Driscoll / jdriscoll

This is probably related to PIL:

http://mail.python.org/pipermail/image-sig/2006-October/004164.html

You can set MAXBLOCK for ImageKit in settings.py (it defaults to 256k):

1
2
3
4
# settings.py
#... other settings

PIL_IMAGEFILE_MAXBLOCK = 1024 * 2 ** 10

See if that helps.


#2 Anonymous

written 6 months ago, last edited unknown.

Thank you very much.. Sorry your bug tracker.


Add comment / attachment

Show/hide preview

Verification: Please write the text from the image in the box (letters only)

captcha

Is that you, Humanoid? Is this me?