Page 1 of 1

TIF to PNG with trim + clip = loss of transparency

Posted: 2017-08-03T08:03:25-07:00
by bsArithnea
Hello,

i have a tiff image, which has a clipping path (and as far as i can tell, it is already transparent).

This command, does its job perfectly fine

Code: Select all

convert apu80365.tif[0] -alpha transparent -clip -alpha opaque clipped.png
Also, if i do this:

Code: Select all

convert apu80365.tif[0] -trim +repage trimmed.png
The result is perfectly fine, the image is trimmed, and it kept the current state (is transparent)

if i combine these commands:

Code: Select all

convert apu80365.tif[0] -alpha transparent -clip -alpha opaque -trim clipped.png
i lose the transparency and the image is black or white (depends on cmyk/srgb)

The example image is here:
https://owncloud.arithnea.de/public.php ... c46c1a811c

thank you very much in advance for your help.

My IM Version:

Code: Select all

Version: ImageMagick 7.0.3-8 Q16 x64 2016-11-24 http://www.imagemagick.org
Best Regards,

Bernhard

Re: TIF to PNG with trim + clip = loss of transparency

Posted: 2017-08-03T09:58:14-07:00
by fmw42
You need to reset the page geometry using +repage after a trim.

Code: Select all

convert apu80365.tif[0] -alpha transparent -clip -alpha opaque -trim +repage clipped

Re: TIF to PNG with trim + clip = loss of transparency

Posted: 2017-08-07T00:14:46-07:00
by bsArithnea
Hello fmw42,

thanks for your reply.

it didnt work with repage, the background is still black for me.

Code: Select all

convert apu80365.tif[0] -alpha transparent -clip -alpha opaque -trim +repage asdf.png
Best Regards,

Bernhard

Re: TIF to PNG with trim + clip = loss of transparency

Posted: 2017-08-07T00:29:20-07:00
by fmw42
Upgrade your Imagemagick version to the latest and try again. Or post your tiff file to some free hosting service that will not reformat your tiff file, such as dropbox.com and put the URL here so we can test it.

Re: TIF to PNG with trim + clip = loss of transparency

Posted: 2017-08-07T02:50:42-07:00
by bsArithnea
i ve already uploaded the image to our owncloud server and posted the link in the first post. i have trouble finding a host which accepts 13 MB TIFF images.

I ve tried it with the latest version of imagemagick:

Code: Select all

"C:\Program Files\ImageMagick-7.0.6-Q16\magick.exe" apu80365.tif[0] -alpha transparent -clip -alpha opaque -trim +repage asdf1.png

Code: Select all

Version: ImageMagick 7.0.6-5 Q16 x64 2017-08-03 http://www.imagemagick.org

ive tried it with rgb/cmyk color profiles, then i get a white background instead of black

Code: Select all

"C:\Program Files\ImageMagick-7.0.6-Q16\magick.exe" apu80365.tif[0] +profile 'icc,icm' -profile ISOcoated_v2_eci.icc -profile sRGB_IEC61966-2-1_black_scaled.icc +profile 'icc,icm' -alpha transparent -clip -alpha opaque -trim +repage asdf1.png

Re: TIF to PNG with trim + clip = loss of transparency

Posted: 2017-08-07T07:21:52-07:00
by GeeMack
bsArithnea wrote: 2017-08-07T00:14:46-07:00it didnt work with repage, the background is still black for me.

Code: Select all

convert apu80365.tif[0] -alpha transparent -clip -alpha opaque -trim +repage asdf.png
Put "-background none" in your command.

Code: Select all

convert apu80365.tif[0] -alpha transparent -background none -clip -alpha opaque -trim clipped.png
That results in a transparent background for me using IM 6.9.8-10 or IM 7.0.6-5 (magick ...) from a Windows 10 command prompt.

Re: TIF to PNG with trim + clip = loss of transparency

Posted: 2017-08-07T10:06:13-07:00
by fmw42
This command works fine for me on IM 6.9.6.5 Q16 Mac OSX Sierra.

Code: Select all

convert apu80365.tif[0] -alpha transparent -clip -alpha opaque -trim +repage clipped.png
On IM 7.0.6.5, it does leave a black background. This would appear to be a bug in IM 7.

However, GeeMack's solution of adding -background none, seems to work for me in IM 7.

Code: Select all

magick apu80365.tif[0] -alpha transparent -background none -clip -alpha opaque -trim +repage clipped.png

Re: TIF to PNG with trim + clip = loss of transparency

Posted: 2017-08-21T01:48:37-07:00
by bsArithnea
Hello and thank you very much for your help,

i ve been a few days off, sorry for the late reply

Ive tried it with -background none (with the latest version of IM) and it worked, the background is transparent again.

Code: Select all

"C:\Program Files\ImageMagick-7.0.6-Q16\magick.exe" apu80365.tif[0] +profile 'icc,icm' -profile ISOcoated_v2_eci.icc -profile sRGB_IEC61966-2-1_black_scaled.icc +profile 'icc,icm' -alpha transparent -background none -clip -alpha opaque -trim +repage asdf1.png
Best Regards,

Bernhard

Re: TIF to PNG with trim + clip = loss of transparency

Posted: 2017-08-21T02:45:59-07:00
by snibgo
Note that "-clip" applies to all following operations. See http://www.imagemagick.org/script/comma ... s.php#clip

It is good practice when you have "-clip" to always have "+clip" somewhere after it, when you no longer need to apply the clipping path to operations.

Re: TIF to PNG with trim + clip = loss of transparency

Posted: 2017-08-21T02:49:02-07:00
by bsArithnea
snibgo wrote: 2017-08-21T02:45:59-07:00 Note that "-clip" applies to all following operations. See http://www.imagemagick.org/script/comma ... s.php#clip

It is good practice when you have "-clip" to always have "+clip" somewhere after it, when you no longer need to apply the clipping path to operations.
Thanks for the hint!

Best Regards,

Bernhard