FreeImagePy creating thumbnails from TIFF

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • geskerrett@hotmail.com

    #1

    FreeImagePy creating thumbnails from TIFF

    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.con stants.FreeImag ePy_ColorWrong: 'Wrong color 1 in
    function: FreeImage_MakeT humbnail. 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.getNu mPages()):
    print 'page;',pg
    bmp = FIPY.Image()
    bmp.new((300,30 0),fileType=FIF _TIFF)
    bmp.setBitmap(i mg)
    bmp.thumbnail(3 00,convert=True )
    bmp.save("first _thumb_"+str(pg ), FIF_PNG)
    img.setCurrentP age(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.

  • Michele Petrazzo

    #2
    Re: FreeImagePy creating thumbnails from TIFF

    geskerrett@hotm ail.com wrote:
    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.con stants.FreeImag ePy_ColorWrong: 'Wrong
    color 1 in function: FreeImage_MakeT humbnail. I can use: (8, 24,
    32)'
    >
    >
    Any suggestions?
    >
    Found a bug!
    Change, into the funct_list, at line 119,
    ('FreeImage_Mak eThumbnail', '@12', (CO.COL_8, CO.COL_24, CO.COL_32) ),
    to
    ('FreeImage_Mak eThumbnail', '@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(fnam e)

    for bmp in img:
    new_img = bmp.thumbnail(3 00)

    Bye,
    Michele

    Comment

    Working...