IOError: encoder error -2 when writing image file

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

IOError: encoder error -2 when writing image file

Viktor Shulika
Hello,

I've the error when try to save jpeg image with PIL

When I use ImageMagic on PHP save without problems.

Image in attachment.

The same error I've got on Mac and Linux

Environment:

Request Method: POST
Django Version: 1.2.3
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.markup',
 'django_extensions',
 'imagekit',
 'compressor',
 'robots',
 'cure',
 'imageofmodel',
 'medicine',
 'mkb10',
 'services',
 'map',
 'accommodation',
 'qa',
 'currencies',
 'prices',
 'phrasebook']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'slimmer.middleware.CompressHtmlMiddleware')

Traceback:

Traceback (most recent call last):
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/staticfiles/handlers.py", line 74, in __call__
    return self.application(environ, start_response)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 265, in __call__
    response = self.get_response(request)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/core/handlers/base.py", line 162, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/admin/options.py", line 298, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/utils/decorators.py", line 93, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/views/decorators/cache.py", line 79, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/admin/sites.py", line 190, in inner
    return view(request, *args, **kwargs)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/utils/decorators.py", line 28, in _wrapper
    return bound_func(*args, **kwargs)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/utils/decorators.py", line 93, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/utils/decorators.py", line 24, in bound_func
    return func(self, *args2, **kwargs2)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/db/transaction.py", line 291, in inner
    res = func(*args, **kwargs)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/admin/options.py", line 953, in change_view
    self.save_formset(request, form, formset, change=True)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/admin/options.py", line 658, in save_formset
    formset.save()
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/forms/models.py", line 501, in save
    return self.save_existing_objects(commit) + self.save_new_objects(commit)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/forms/models.py", line 638, in save_new_objects
    self.new_objects.append(self.save_new(form, commit=commit))
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/contenttypes/generic.py", line 354, in save_new
    return save_instance(form, new_obj, commit=commit)
  File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/forms/models.py", line 87, in save_instance
    instance.save()
  File "/opt/local/lib/python2.5/site-packages/django_imageofmodel-0.0.5-py2.5.egg/imageofmodel/models.py", line 79, in save
    super(self.__class__, self).save(*args, **kwargs)
  File "/opt/local/lib/python2.5/site-packages/django_imagekit-0.3.3-py2.5.egg/imagekit/models.py", line 145, in save
    self._pre_cache()
  File "/opt/local/lib/python2.5/site-packages/django_imagekit-0.3.3-py2.5.egg/imagekit/models.py", line 110, in _pre_cache
    prop._create()
  File "/opt/local/lib/python2.5/site-packages/django_imagekit-0.3.3-py2.5.egg/imagekit/specs.py", line 65, in _create
    content = ContentFile(self._get_imgfile().read())
  File "/opt/local/lib/python2.5/site-packages/django_imagekit-0.3.3-py2.5.egg/imagekit/specs.py", line 50, in _get_imgfile
    optimize=True)
  File "/opt/local/lib/python2.5/site-packages/django_imagekit-0.3.3-py2.5.egg/imagekit/utils.py", line 7, in img_to_fobj
    img.save(tmp, format, **kwargs)
  File "/opt/local/lib/python2.5/site-packages/PIL/Image.py", line 1405, in save
    save_handler(self, fp, filename)
  File "/opt/local/lib/python2.5/site-packages/PIL/JpegImagePlugin.py", line 409, in _save
    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
  File "/opt/local/lib/python2.5/site-packages/PIL/ImageFile.py", line 493, in _save
    raise IOError("encoder error %d when writing image file" % s)
IOError: encoder error -2 when writing image file

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig

=?KOI8-R?B?0sXT1C5qcGc=?= (231K) Download Attachment