ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> image-sig
image-sig
Re: [Image-SIG] generating images of different sizes
by Rajorshi Biswas other posts by this author
Jul 22 2004 5:01AM messages near this date
Re: [Image-SIG] Hi from Argentina | [Image-SIG] generating images of different sizes
Thanks a lot Larry. That indeed does help! You see,
I have a strange type of requirement wherein I have to
generate image files of a particular resolution having
as large a file size as possible.
 Initially I was trying this by getting a high quality 
jpeg or bmp file, and converting this *without* any
options to PIL's Image.save. I was only partly successful.
For instance, I need a 352x288 jpeg of 300-350 KB size,
but I am about 200 KB short. Then I tried a different
approach - creating an image in PIL from scratch and
using ImageDraw's methods to go on adding lines, points 
etc until the filesize came close to what I wanted. But 
I found the size saturating at a point (far less than
the filesize I wanted though).
 Is there a better way of doing what I want ?

Thanks for the help mate!
Rajorshi


On Wed, 21 Jul 2004 13:57:13 -0500
"Larry Bates" <lbates@[...].com>  wrote:

>  Since PIL cannot (at the current time) support compressed
>  TIFF images, you cannot reduce their size by any options
>  from within PIL.  When I need to produce compressed TIFF
>  images, I use external program like tiffcp to handle the
>  compression (of course I do it by calling it from within
>  my Python program via os.system() call).
>  
>  I normally look into the source code for each different 
>  PIL plug-in to see what options are available.  The files
>  will be in the format ???ImagePlugin.py and are normally
>  located in /lib/site-packages/PIL subdirectory.
>  
>  Below is a snippet of code that shows the keywords for
>  JPEG plug-in:
>  
>      # get keyword arguments
>      im.encoderconfig = (
>          im.encoderinfo.get("quality", 0),
>          im.encoderinfo.has_key("progressive"),
>          im.encoderinfo.get("smooth", 0),
>          im.encoderinfo.has_key("optimize"),
>          im.encoderinfo.get("streamtype", 0),
>          dpi[0], dpi[1]
>          )
>  
>  This means he understands quality, progessive, smooth,
>  optimize, and streamtype keywords.  The only one I've
>  ever actually used it quality.
>  
>  HTH, Larry Bates
>  
>  
>  -----Original Message-----
>  From: Rajorshi Biswas [mailto:rajorshi@[...].com]
>  Sent: Tuesday, July 20, 2004 6:19 AM
>  To: image-sig@[...].org
>  Subject: [Image-SIG] generating images of different sizes
>  
>  
>  Hi,
>   This is my first post to the image-sig mailing list, so
>  hello to you all.
>   My knowledge of different file formats is somewhat limited.
>  What I have to do is essentially this : Given a resolution
>  (such as 352x288) and a file-size (such as 300KB), I have
>  to generate images using PIL of the following formats:
>  [ jpeg, gif, wbmp, bmp, png, tiff ]. 
>   I have achieved the first part, that is I can, starting
>  from a jpg image, generate all the other types with any
>  resolution (by resizing and using PIL's Image.save). But
>  I have no control over file size.
>   To do that I found that there's a variant of the Image.save
>  method that takes in a third parameter:
>  Image.save( filename, format, options ).
>   The PIL manual says that 
>  "Keyword options can be used to provide additional 
>  instructions to the writer. If a writer doesn't recognise 
>  an option, it is silently ignored. The available options 
>  are described later in this handbook."
>   Could someone please tell me what these options are ?
>  I seem to be unable to find the 'options' in the manual.
>  If it is not there, could someone tell me,
>  
>  1] What i need to do to reduce the size of the tiff files
>  I generate, what options I need to add to the call
>  Image.save('a.tiff') .
>  
>  2] Same for bmp files.
>   
>   That's a lot of queries for the first post! Please help!
>  
>  Thanks.
>  Rajorshi
>  
>  
>  
>  
>  
>  


-- 
-----------------------------------

Rajorshi Biswas

Trainee, Alumnus Software Ltd.
INFINITY, Tower II, 2nd Floor.
Plot - A3, Block - GP, Sector V
Salt Lake City, Kolkata 700 091
West Bengal, India

Phone     : +91 33 2357 5626/27/28 
Extension : 357/355
Alternate : rajorshi@[...].fm
Website   : http://www.rajorshi.tk

-----------------------------------


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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved