Convert PNG to TIFF with Transparency and CMYK

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Faria
Posts: 5
Joined: 2012-11-30T02:17:36-07:00
Authentication code: 6789

Convert PNG to TIFF with Transparency and CMYK

Post by Faria »

Hi Guys,

I am trying hard to convert PNGs to TIFFs using a Batch File. However, the resulting files lack transparency.

S:\*.*\mogrify -path H:\*.*\blau -format tiff H:\*.*\Raw\*.png
pause
S:\*.*\mogrify -fuzz 20%% -fill blue -opaque black H:\*.*\blau\*.tiff
S:\*.*\mogrify -colorspace cmyk H:\*.*\blau\*.tiff
S:\*.*\mogrify -fuzz 60%% -transparent white H:\*.*\blau\*.tiff

The TIFFs have a white background afterwards which I have verified using PhotoShop. What is wrong here? How can I get the resulting files to not lose transparency?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert PNG to TIFF with Transparency and CMYK

Post by fmw42 »

use colors that include the alpha channel. see http://www.imagemagick.org/script/color.php

example rgba(....)
Faria
Posts: 5
Joined: 2012-11-30T02:17:36-07:00
Authentication code: 6789

Re: Convert PNG to TIFF with Transparency and CMYK

Post by Faria »

But theres nothing like CMYKa, is it?
Imagemagick doesnt support RGBA? If i try -colorspace rgba i get an error

Edit:

Tried SRGB... I can see a Black part on the right side now?

Edit Edit:

Here comes the tricky thing: If I do it with convert and only 1 pic at a time it works...!! WHY?!

Code: Select all

convert -transparent white objekt.jpg objekt.tiff
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert PNG to TIFF with Transparency and CMYK

Post by fmw42 »

But theres nothing like CMYKa, is it?
Yes, you can specify CMYKA colors. But there is no rgba or cmyka colorspace. The alpha is not specified in the colorspace conversion.

See http://www.imagemagick.org/script/color.php

However, for some reason it does not show that. However, you should be able to use the color converter link and get CMYKA values or specify CMYKA values.

This should work if you specify colors as rgba(...)

S:\*.*\mogrify -fuzz 20%% -fill blue -opaque black H:\*.*\blau\*.tiff



I am not sure here why you want to change colorspace?
S:\*.*\mogrify -colorspace cmyk H:\*.*\blau\*.tiff


This won't work as the -transparent will start over creating a new alpha channel
S:\*.*\mogrify -fuzz 60%% -transparent white H:\*.*\blau\*.tiff
Faria
Posts: 5
Joined: 2012-11-30T02:17:36-07:00
Authentication code: 6789

Re: Convert PNG to TIFF with Transparency and CMYK

Post by Faria »

I tried to specify the alpha channel the whole day...

The point is, that if I do it with convert it works without any problems on my desktop... by changing to my network drive it wont work at all! (with mogrify AND convert...)

And I have to change it to cmyk afterwards... maybe I posted a script with a test... ^^


Ahhhh and the color changing from blue to black works perfectly, the TRANSPARENCY doesnt work =(
Faria
Posts: 5
Joined: 2012-11-30T02:17:36-07:00
Authentication code: 6789

Re: Convert PNG to TIFF with Transparency and CMYK

Post by Faria »

I tried now:

Code: Select all

*.*\ImageMagick\mogrify -path \\*.*\blau -format tiff -fuzz 20%% -fill "rgba( 0, 0, 255, 1.0)" -opaque black -fuzz 20%% -transparent white \\*.*\Raw\*.png


*.*\ImageMagick\mogrify -fuzz 60%% -transparent "rgba( 255, 255, 255, 1.0)" *.*\*.tiff





Doesnt work at ALL!! >.< what am I doing wrong... There is no transparency afterwards... even if I try it with 0.0 in the alpha channel
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert PNG to TIFF with Transparency and CMYK

Post by fmw42 »

post a link to your image, so we can test with it.

also try replacing black in the first command with "rgba(0,0,0,1)"

using -transparent is not going to do what you want as it will destroy your alpha channel and make a new one
Faria
Posts: 5
Joined: 2012-11-30T02:17:36-07:00
Authentication code: 6789

Re: Convert PNG to TIFF with Transparency and CMYK

Post by Faria »

Hi,

I'm not allowed to post one of these pictures as they contain personal information of our clients.. =(


well... but how can I achieve transparency without using -transparent?


with -fill "rgba( 0, 0, 255, 0.0)" -opaque "rgba( 0, 0, 255, 1.0)"?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert PNG to TIFF with Transparency and CMYK

Post by fmw42 »

with -fill "rgba( 0, 0, 255, 0.0)" -opaque "rgba( 0, 0, 255, 1.0)"?
That should work to make opaque blue into transparent blue without changing any existing transparency. You may have to add -alpha on -channel rgba before that, but not sure without testing.

I don't recall that you have identified your version of IM or platform. So if you have an old version of IM it may have a bug.

The following works for me.

# create transparency for white
convert logo: -transparent white logo1.png

# add transparency for some shades of blue
convert logo1.png -alpha on -channel rgba -fuzz 30% -fill "rgba(0,0,255,0)" -opaque "rgba(0,0,255,1)" logo2.png


Test that and see if it works for you.
Post Reply