FreeImagePy creating thumbnails from TIFF

G

geskerrett

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.
 
M

Michele Petrazzo

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?

Found a bug!
Change, into the funct_list, at line 119,
('FreeImage_MakeThumbnail', '@12', (CO.COL_8, CO.COL_24, CO.COL_32) ),
to
('FreeImage_MakeThumbnail', '@12', CO.COL_1TO32 ),
and it'll work.
Or update to the new svn version (r21), that adds the
__iter__ method for the Image class. Now you can do this:

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

for bmp in img:
new_img = bmp.thumbnail(300)

Bye,
Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top