[reportlab-users] Importing a gif-graphic in reportlab

Robin Becker reportlab-users@reportlab.com
Wed, 2 Apr 2003 17:13:49 +0100


In article <5AA9CE8C-6518-11D7-A501-00039345C610@darwin.in-berlin.de>,
Dinu Gherman <gherman@darwin.in-berlin.de> writes
>Florian Reiser:
>
>> I want to import a gif-graphic into reportlab by using drawImage.
>> However the graphic is converted to jpeg-format and looses a 
>> significant
>> amount of quality.
>> So the lines of the chart as well as the letters get blurred.
>> How can I avoid this?
>> Is there any function in PIL or reportlab which can assure that the
>> quality of the included
>> graphic remains high?
>
>I'm teasing Robin for many weeks now to do something about a very
>similar issue, but in drawings. If all of us find two mates to
>complain we could quickly build up a critical mass... ;-)
>
>Dinu
>
>--
>Dinu C. Gherman
I don't really mind being teased :)

I'm surprised that JPEG is being used with GIF though. According to my
understanding of PDFImageXObject (in pdfbase/pdfdoc.py) jpeg is used
only if the name has a .jpg/.jpeg extension. Otherwise if the name is a
string we try for a cached file and if that doesn't exist we go through
PIL and convert to RGB then A85.
If the passed in thing was a PIL image object then we try and convert
that directly.

However, the conversion is carried out using the simplistic
im.convert("RGB"). Any better ideas and I'll be glad to try and add a
mechanism to get the conversion done properly.

One idea might be some way to indicate a 'raw' PIL image which needs no
conversion.
-- 
Robin Becker