I am trying to generate qr codes using elaphe in a django view. This works fine in the development server but fails under production which is running on apache2 and mod_wsgi (on the same machine as development). Looks to be some kind of ghostscript error. I am guessing something to do with the path environment (gs is installed in /usr/local/bin).
Error
Exception Type: IOError
Exception Value:
[Errno 32] Broken pipe
/usr/local/web/django/www/production/recipemonkey/recipemonkeyapp/views/groceryitem.py in barcodeimg
- img.save(response, 'PNG') ...
/usr/local/web/django/www/production/env/recipemonkey/lib/python2.7/site-packages/PIL/Image.py in save
- self.load() ...
/usr/local/web/django/www/production/env/recipemonkey/lib/python2.7/site-packages/PIL/EpsImagePlugin.py in load
- self.im = Ghostscript(self.tile, self.size, self.fp) ...
/usr/local/web/django/www/production/env/recipemonkey/lib/python2.7/site-packages/PIL/EpsImagePlugin.py in Ghostscript
- gs.write(s) ...
Code
def barcodeimg(request, id):
try:
i = GroceryItem.objects.get(pk=id)
except GroceryItem.DoesNotExist:
raise Http404
response=HttpResponse(content_type='image/png')
url="http://%s/recipemonkeyapp/scan/groceryitem/%s" % ('192.168.0.8:8082',i.id)
img=barcode('qrcode',url,options=dict(version=9, eclevel='M'), margin=0, data_mode='8bits') # Generates PIL.EpsImageFile instance
img=img.resize((90,90)) #both these lines generate IOErrors
img.save(response, 'PNG') #both these lines generate IOErrors
return response