PNG2TIFF width transparent background

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?".

PNG2TIFF width transparent background

Postby janberend » 2010-02-08T12:22:36+00:00

I'm a bit frustrated right now
I want to convert a PNG with a transparent background to a tiff with also a transparent background.
And i tried a lot of things. But i can't figure it out. :(

The generated tiff have an alpha channel, i don't think i want that
The background is transparent but the transparent parts of the image turn into black.

Some of the thing i've tried
convert test.png -channel CMYKA -colorspace CMYK -background transparent -flatten -threshold 0 test.tiff
convert test.png -channel CMYKA -colorspace CMYK -alpha Background test.tiff
convert test.png -channel CMYKA -colorspace CMYK -background transparent -alpha copy test.tiff
convert test.png -channel CMYKA -colorspace CMYK -background transparent -alpha none test.tiff

Can you help?

Jan-Berend
janberend
 
Posts: 4
Joined: 2010-01-10T15:14:38+00:00

Re: PNG2TIFF width transparent background

Postby fmw42 » 2010-02-08T16:19:53+00:00

try

convert image.png -channels rgba -alpha on -colorspace cmyk image.tif

if that does not work, then post a link to your png image and someone can test this out.
User avatar
fmw42
 
Posts: 14995
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: PNG2TIFF width transparent background

Postby janberend » 2010-02-15T13:33:00+00:00

Thanks for your answer.
By the way ist -channel in stead of -channels.
The conversion dit not work, still got a white background and an Alpha layer.

Code: Select all
convert test.png -channel rgba -alpha on -colorspace cmyk test.tif


I've uploaded both files
http://www.shirtzilla.nl/images/test.png
http://www.shirtzilla.nl/images/test.tif
janberend
 
Posts: 4
Joined: 2010-01-10T15:14:38+00:00

Re: PNG2TIFF width transparent background

Postby snibgo » 2010-02-15T15:23:28+00:00

I don't understand.

I want to convert a PNG with a transparent background to a tiff with also a transparent background.


This will do that:

Code: Select all
convert test.png test.tif


The generated tiff have an alpha channel, i don't think i want that


You can't have a transparent background without an alpha channel (as far as I know).
snibgo's IM pages: im.snibgo.com
snibgo
 
Posts: 3942
Joined: 2010-01-23T23:01:33+00:00

Re: PNG2TIFF width transparent background

Postby fmw42 » 2010-02-15T16:26:27+00:00

there is nothing wrong with your test.png image and

convert test.png test.tiff

works just fine on IM 6.5.9-5 Q16 Mac OSX Tiger. As user snibgo said, you cannot have transparency without an alpha channel.

I am not sure what you are doing to get your test.tiff. It is just the alpha channel negated or the base image with blue turned to black.

What is your exact command and what version of IM are you using?

Why is your first command above trying to convert to CMYK. If you want the transparency, then you need to use

convert test.png -channel rgba -alpha on -colorspace cmyk test.tiff


That produces a tiff in CMYK with an alpha channel, but the colors will be changed to dark blue due the change to cmyk so that may be what you are seeing in your test.tiff when you view it.

This is confirmed when you do:

identify -verbose test.tif
Image: test.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 200x200+0+0
Resolution: 28.34x28.34
Print size: 7.05716x7.05716
Units: PixelsPerCentimeter
Type: ColorSeparationMatte
Base type: ColorSeparation
Endianess: MSB
Colorspace: CMYK
Depth: 8/4-bit
Channel depth:
cyan: 1-bit
magenta: 1-bit
yellow: 1-bit
black: 4-bit
alpha: 1-bit
Channel statistics:
Cyan:
min: 0 (0)
max: 65279 (1)
mean: 52.6703 (0.20655)
standard deviation: 103.232 (0.40483)
kurtosis: 0.101762
skewness: 1.44975
Magenta:
min: 0 (0)
max: 65279 (1)
mean: 52.6703 (0.20655)
standard deviation: 103.232 (0.40483)
kurtosis: 0.101762
skewness: 1.44975
Yellow:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: -0 (-0)
kurtosis: 0
skewness: 0
Black:
min: 0 (0)
max: 26163 (0.2)
mean: 10.5341 (0.04131)
standard deviation: 20.6463 (0.0809659)
kurtosis: 0.101762
skewness: 1.44975
Alpha:
min: 255 (1)
max: 0 (0)
mean: 52.6702 (0.20655)
standard deviation: 103.232 (0.40483)
kurtosis: 0.101762
skewness: -1.44975
User avatar
fmw42
 
Posts: 14995
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: PNG2TIFF width transparent background

Postby janberend » 2010-02-18T08:15:28+00:00

I have some additional information to make clear my question

Image
janberend
 
Posts: 4
Joined: 2010-01-10T15:14:38+00:00

Re: PNG2TIFF width transparent background

Postby snibgo » 2010-02-18T08:26:37+00:00

What version of IM are you using?

When I use
convert test.png test.tif
(version 6.4.5) my result looks like what you want.
snibgo's IM pages: im.snibgo.com
snibgo
 
Posts: 3942
Joined: 2010-01-23T23:01:33+00:00

Re: PNG2TIFF width transparent background

Postby janberend » 2010-02-18T09:04:11+00:00

Both the same result

Windows
Version: ImageMagick 6.5.7-0 2009-10-15 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

Debian Linux
Version: ImageMagick 6.3.7 08/07/09 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC
janberend
 
Posts: 4
Joined: 2010-01-10T15:14:38+00:00

Re: PNG2TIFF width transparent background

Postby fmw42 » 2010-02-18T10:58:14+00:00

First of all, PNG does not support CMYK to my knowledge, so you have started with something else apart from a CMYK png. Your test.png is RGB. Perhaps you started with that and changed the colorspace in PS to cmyk for the PS temp image that is displayed until you saved it as TIF.

I only have PS CS (so rather old). Apparently PS does not interpret the alpha channel in CMYKA images the same as in IM. I see the same white background results as you when I convert the test.png (with alpha) to cmyka tif using IM. IM and other programs I have display the transparency properly. I do not know why Photoshop does not except to assume it handles the alpha in cmyka differently. I am not sure if there is a way to apply the separate alpha channel you see in your text.tiff to the other channels as you have when you converted/created it in PS. In your other images, the transparency has been applied to each channel. There is no separate alpha layer. In the IM created image, PS has not applied the alpha layer it to the other channels and has just kept it as a separate layer.

If you click in the little box to the left of the alpha1 it turns on that layer, but in my system it then shows as pink outside the blue.

I don't know PS that well. Perhaps there is some PS expert on the forum that might be able to figure this out or clarify things further.
User avatar
fmw42
 
Posts: 14995
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: PNG2TIFF width transparent background

Postby altFusion » 2010-03-29T06:32:20+00:00

Hi there, I am new to the forums and indeed new to ImageMagick. But I had this problem and was brought in here so I thought I would add my findings in case they help.

I am not totally sure what is going on either but I wanted to change the DPI and size and then convert from PNG to TIF and I got the same results as on here (When loading back into photoshop CS I see a black background and not a transparent background)

My 2 commands are quite simple:
Code: Select all
 exec("convert -density 300x300 -units PixelsPerInch -resize 3600x4500 altResampledImages/72/LJMTest72.png altResampledImages/300/LJMTestTry1.png");
 exec("convert altResampledImages/300/LJMTestTry1.png altResampledImages/300/LJMTestTry1.tif");


I split the 2 commands out purely to make sure the PNG2TIF wasnt affected by all the DPI changes and wotnot.
I am also not messing around with CMYK or RGB and Alpha channels.
So like I say, in Photoshop CS I get the black background as well. However, when I right click the file and say "View in Windows Photo Gallery" Then the background is white. So that says to me that the actual TIF file isnt specifying a black background, it is just Photoshop that cant handle the background.
I am now going to the customer to see if they use photoshop for their needs for the result image. If they dont and they use something else that does in fact see a transparent background then there is probably no need for me to try and fix this issue. We can just put it down to being Photoshops fault heheh.


One issue is that MS Paint also doesnt open the TIF file which is a little nerve racking however that could just be due to the 300dpi setting of it perhaps?


Cheers,

Hector.
altFusion
 

Re: PNG2TIFF width transparent background

Postby snibgo » 2010-03-29T07:08:36+00:00

You should remember that a transparent pixel still carries RGB data. A program that displays that pixel might choose to (a) show white instead, (b) show black instead, (c) show part of a grey chequerboad pattern instead (d) show the RGB value or (e) do something else, like showing the window that lies behind the display window.
snibgo's IM pages: im.snibgo.com
snibgo
 
Posts: 3942
Joined: 2010-01-23T23:01:33+00:00


Return to Users

Who is online

Users browsing this forum: Bing [Bot], Google Adsense [Bot], TurnitinBot [Bot] and 17 guests