FreeImagePy creating thumbnails from TIFF

geskerrett at hotmail.com geskerrett at hotmail.com
Mon Oct 23 12:06:46 EDT 2006


I a trying to create a series of thumbnail images from a multpage TIFF
file.  The sample code is below.  When it executes, we get the
following error;
FreeImagePy.constants.FreeImagePy_ColorWrong: 'Wrong color 1 in
function: FreeImage_MakeThumbnail. I can use: (8, 24, 32)'

Any suggestions?

fname = "01-PJ2306.tif"
img = FIPY.Image()
img.load(fname)

#NOTE: the follow method results"
#getFormat: ((18, 0), ('TIFF', 'MINISWHITE'), (200, 200))
#getColorUsed: 2
#getNumPages: 8

for pg in range(img.getNumPages()):
    print 'page;',pg
    bmp = FIPY.Image()
    bmp.new((300,300),fileType=FIF_TIFF)
    bmp.setBitmap(img)
    bmp.thumbnail(300,convert=True)
    bmp.save("first_thumb_"+str(pg), FIF_PNG)
    img.setCurrentPage(pg+1)
    del bmp

Using the above "img" we were able to successfully create the seperate
pages as PNG files in a working directory, however, our goal is to use
to display a series of thumbnails in a wxpython application.  The app
will stored references back to the orginal document with the
correspondng page number.   Essentially we want to avoid having to
"cleanup" a working directory of the PNG pages.
... but if someone has suggestions on this, we are interested too !

Thanks in avance.




More information about the Python-list mailing list