After calling convertToMinIsWhite on an image, image altering functions silently fail. I've tested with MakeThumbnail and Rescale, and both return an all zeros image when called on an image altered by convertToMinIsWhite. By all zeros I mean that the BPP is 0, the width and height are 0, everything appears to be 0, regardless of what the image was before the call to MakeThumbnail or Rescale.
Simple example that causes the problem for me, where image is a TIFF file loaded from disk:
convertedImage = freeimage.convertToMinIsWhite( image ) )
thumbnailImage = freeimage.MakeThumbnail( convertedImage, 100, True )
freeimage.GetBPP( thumbnailImage ) == 0
Worse yet, the problem persists between saving the converted to min is white image to disk and reloading, and none of the conversion functions seem to fix the problem (like ConvertToStandardType, or ConvertTo24Bits), thus rendering FreeImagePy incapable of working with a min is white image.
Tested with the latest version available, 2.0.1, and freeimage library 3.10.0.
Seeing my code there is there a control before do the conversion. the image must be minisblack (freeimagepy.py line 1588) and if isn't, I silently return. Ok, can be a right modify to return 1, for example, if there is an error, but for now you can control the image before pass it to convertToMinIsWhite
Michele
I don't think the minisblack check in convertToMinIsWhite is important, as I've checked and the images are all minisblack before the conversion. Unfortunately, I can't just do the other conversions first, as I have a database of images already previously converted to miniswhite that I'm trying to resize, and this bug is rendering FreeImagePy unusable for working with those.
> I don't think the minisblack check in convertToMinIsWhite is important
Yes that it's important! If the image aren't minisblack, the converter method cannot transfor to miniswhite!
A try that I just make:
michele@portatile:~/tmp$ ls
in.tif test_tiff_bw.py
michele@portatile:~/tmp$ tiffinfo in.tif |grep Photo
Photometric Interpretation: min-is-black
michele@portatile:~/tmp$ cat test_tiff_bw.py
import FreeImagePy as F
f = F.Image("in.tif")
print f.GetColorType(f.bitmap)
f.convertToMinIsWhite(f.bitmap)
f.save("out.tif")
michele@portatile:~/tmp$ python test_tiff_bw.py
1
# (according to the constants, 1 is minisblack)
michele@portatile:~/tmp$ tiffinfo out.tif |grep Photo
Photometric Interpretation: min-is-white
So here FIPY it's working