jdriscoll/django-imagekit — Issue #50: image in feeds.py
Author: rizumu
Created: 2011-11-04 12:43:54+00:00
State: open

I am getting an error when an thumbnail doesn't exist in the cache for an image used in a rss feed.
`handler.addQuickElement(u"url", show.img_itunes_sm.url)` from https://github.com/rizumu/django-podcasting/blob/master/podcasting/feeds.py

The error is triggerd in utils.py when calling img.save():

```
ipdb> img

ipdb> img.save(tmp, format, **kwargs)
Suspension not allowed here
*** IOError: encoder error -2 when writing image file
```

and the traceback

```
Environment:

Request Method: GET
Request URL: http://snowprayers.net/feeds/podcasts/snowprayers/itunes/mp3/rss/

Traceback:
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/newrelic-0.5.58.122/newrelic/hooks/framework_django.py" in __call__
327. return self.__wrapped(*args, **kwargs)
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/django/contrib/syndication/views.py" in __call__
39. feedgen.write(response, 'utf-8')
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/django/utils/feedgenerator.py" in write
214. self.add_root_elements(handler)
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/podcasting/feeds.py" in add_root_elements
39. handler.addQuickElement(u"itunes:image", attrs={"href": show.img_itunes_lg.url})
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/imagekit/models.py" in url
159. self._create(True)
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/imagekit/models.py" in _create
184. img, content = self._process_content(self.name, fp)
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/imagekit/models.py" in _process_content
135. optimize=True)
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/imagekit/utils.py" in img_to_fobj
18. img.save(tmp, format, **kwargs)
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/PIL/Image.py" in save
1439. save_handler(self, fp, filename)
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/PIL/JpegImagePlugin.py" in _save
471. ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
File "/home/deploy/.virtualenvs/snowprayers/lib/python2.7/site-packages/PIL/ImageFile.py" in _save
501. raise IOError("encoder error %d when writing image file" % s)

Exception Type: IOError at /feeds/podcasts/snowprayers/itunes/mp3/rss/
Exception Value: encoder error -2 when writing image file
```

I'll attempt to figure it out over the weekend.