Webfaction Django 1.4.1: easy_thumbnails 3.0b – Couldnt get the thumbnail error

2024/10/13 16:20:09

I use easy_thumbnails and it works fine on a development machine but in production I get errors like shown below, when I use {% thumbnail photo.image 300x170 %} templatetag.

Though can directly browse http://sitename.com/media/uploads/2012/09/13/microsoft1.jpeg`. Also media set correctly and uploads are being placed at the right place, what is missing then what might be wrong?

File "/home/imanhodjaev/lib/python2.7/django/template/base.py" in render823. bit = self.render_node(node, context)
File "/home/imanhodjaev/lib/python2.7/django/template/debug.py" in render_node74. return node.render(context)
File "/home/imanhodjaev/lib/python2.7/easy_thumbnails/templatetags/thumbnail.py" in render99. (source, e))
Exception Type: TemplateSyntaxError at /petition/microsoft-myi-hotim-kyirgyizskij-rasklad-klaviatur/update-picture
Exception Value: Couldn't get the thumbnail uploads/2012/09/13/microsoft1.jpeg: The source file does not appear to be an image

Model

ThumbnailerImageField from easy_thumbnails is used

class Petition(models.Model):title = models.CharField(max_length=512)slug = models.SlugField(max_length=512, editable=False, blank=True)description = models.TextField()petition_text = models.TextField(blank=True, null=True)petition_picture = ThumbnailerImageField(upload_to=get_upload_path, blank=True)

Update

I did investigation from Django's management shell and get_thumbnailer function works fine

>>> thumb_url = get_thumbnailer(pet.petition_picture)
>>> thumb_url
<ThumbnailerImageFieldFile: uploads/2012/09/13/microsoft1.jpeg>
>>> thumb_url.url
'/m/uploads/2012/09/13/microsoft1.jpeg'

And when I call get thumbnail method it fails

>>> thumb_url = get_thumbnailer(pet.petition_picture).get_thumbnail(options)
Traceback (most recent call last):File "<input>", line 1, in <module>File "/home/imanhodjaev/lib/python2.7/easy_thumbnails/files.py", line 380, in get_thumbnailthumbnail = self.generate_thumbnail(thumbnail_options)File "/home/imanhodjaev/lib/python2.7/easy_thumbnails/files.py", line 290, in generate_thumbnail"The source file does not appear to be an image")
InvalidImageFormatError: The source file does not appear to be an image
Answer

The problem was because of by default pip install PIL on my Webfaction instance was linked with libjpeg so did pip install PIllow and followed the article at http://community.webfaction.com/questions/7340/how-to-install-pil-with-truetype-support

https://en.xdnf.cn/q/118059.html

Related Q&A

acronym replacement with its value using python

i have dictionary like that i need to replace acronyms in text with its value in dictionary i use this code but it doesnt give me the appropriate result when i test the function using acronyms("we…

Grako - How to do error handling?

How do I do error handling with Grako?EBNF (MyGrammar.ebnf):pattern = { tag | function }* ; tag = tag:( "%" name:id "%" ); function = function:("$" name:id "…

How get the softlayer storage credendials?

Im trying to get the Username,password and host IQN of a authorized Softlayer Network Storage. I used this python script, but the shell returns []import SoftLayerAPI_USERNAME = xxxAPI_KEY = yyyystorage…

dopy.manager.DoError: Unable to authenticate you

Im trying to configure a Virtual Machine(with Vagrant and Ansible), that needs a file.py to the full correct configuration of this machine (according to the book that Im studying),Im was using the Digi…

subprocess.Popen: OSError: [Errno 2] No such file or directory only on Linux

This is not a duplicate of subprocess.Popen: OSError: [Errno 13] Permission denied only on Linux as that problem occurred due to wrong permissions. That has been fixed and this is an entirely different…

Windows Theano Keras - lazylinker_ext\mod.cpp: No such file or directory

I am installing Theano and Keras follwing the How do I install Keras and Theano in Anaconda Python on Windows?, which worked fine for me with an older release before. Now I have upgraded to the latest…

Python Threading: Making the thread function return from an external signal

Could anyone please point out whats wrong with this code. I am trying to return the thread through a variable flag, which I want to control in my main thread. test27.pyimport threading import timelock …

Python join data lines together

Hello i have dataset a few thousand lines which is split in even and odd number lines and i cant find a way to join them together again in the same line. Reading the file and overwriting it is fine or …

How to undraw plot with Zelle graphics?

This is a code problem for Python 3.5.2 using John Zelles graphics.py:I have spent a good amount of time looking for the answer here, but just can not figure it out. The function undraw() exists just l…

/bin/sh: line 62: to: command not found

I have a python code in which I am calling a shell command. The part of the code where I did the shell command is:try:def parse(text_list):text = \n.join(text_list)cwd = os.getcwd()os.chdir("/var/…