I'm trying to convert TIFF files to PNG, by keeping transparency and avoiding many caveats coming from strange TIFF files.
These Tiff files can come from various sources (uploaded by users),
and the conversion should work as if we did it by simply opened the file in a image Editor and convert it into PNG.
I guess these files were created in PhotoShop.
I figured out a lot of problem for now, the only remaining problem is about transparency on some of them.
Here is a source file that I can share.
You'll see :
- it contains only 1 layer, which is a vector object
- vector object has a lot of layers, including a mask at the beginning
- the vector object is a rounded square
- space around this rounded square is transparent
When using :
Code: Select all
convert source.tif dest.png
0 is the correct size, but with a white background
1 has the transparent, but the size not correct
First question: Why ImageMagick identify 2 layers?
Then, when using
Code: Select all
convert -define 'tiff:ignore-layers=true' -define 'tiff:alpha=unassociated' source.tif -background none -flatten +repage -strip dest.png
The define tags are here in order to fix other problem I encounter. Removing them have no influence on the result.
I can use the replace color technique, as there might have white pixel inside the image that shouldn't be transparent.
Main Question: How can I correctly convert this tif file into a transparent PNG?
I googled for hours about this problem, tested a lot of different combination and can't find a valid solution.
I'm using ImageMagick 6.9.7-4 (Debian)
I've also tested it with ImageMagick 7.0.8-40 through docker and the problem is exactly the same.
Thanks in advance.