views:

119

answers:

1

Hi guys, I am a newbee to django and jython. I need to create and save image thumbnails in database. I am using django running on jython and mysql database. I was exploring python imaging library, but the i found out that i wont work with jython.

How do i create image thumbnails using jython and then save them in mysql db?? Any kind of help will be appreciated. thanx

+1  A: 

There are projects like sorl-thumbnail which is a great and easy to use django app for thumbnailing. But it also depends on PIL so you can't use it, that is bad news. Good news is since in jython you have access to all goods of java libs you can possibly use one of java code snippets available on the net, google: "java how to create thumbnails" (I didn't check any of them).

On the other side, in my project, I used ImageMagick's convert command-line tool (-resize or -thumbnail option). It gives very good quality thumbnails which are also optimized in terms of size if you use -strip with -resize or -thumnbail option alone (unnecessary info is stripped). The downside is that you need to operate on files and then fetch thumnbail back to mysql.

greetings,

Łukasz Korzybski
thank you Lukasz. i will try out the command line tool and bug you in case i have any queries.regards
Nitin Garg
Example invocation of convert: convert -strip -quality 85 -resize "100x100" input.jpg output_thumbnail.jpgand you can call it using subprocess.call: ret_code = subprocess.call(command, shell=True)good luck.
Łukasz Korzybski