Page 1 of 2
-type command not working
Posted: 2010-01-27T11:59:44-07:00
by gotskill10
I've tried this on ImageMagick 6.5.9-0 and 6.4.5.
curl -O
http://s3.amazonaws.com/mixbook/4.png
convert 4.png -type TrueColor 5.png
identify -verbose 5.png | grep "Type"
>> Type: Bilevel
The image is an all black image, but I'm trying to get it to read as TrueColor, as if it had many colors. According to (
http://www.imagemagick.org/script/comma ... s.php#type), this is possible to force using the "-type".
What am I missing here. This seems incredibly straightforward.
Re: -type command not working
Posted: 2010-01-27T13:32:42-07:00
by gotskill10
Can anyone try this and let me know if it works for them?
Re: -type command not working
Posted: 2010-01-27T16:35:28-07:00
by magick
Use -define png:color-type=2. See
http://www.imagemagick.org/script/comma ... php#define about the PNG defines.
Re: -type command not working
Posted: 2010-01-27T17:31:20-07:00
by fmw42
I have tried this for a test, but it gives an error message. Am I doing something wrong?
convert logo: -resize 50% -colorspace gray -transparent white logo2gt.png
identify -verbose logo2gt.png
Format: PNG (Portable Network Graphics)
Class: PseudoClass
Geometry: 320x240+0+0
Resolution: 72x72
Print size: 4.44444x3.33333
Units: Undefined
Type: GrayscaleMatte
Base type: GrayscaleMatte
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
Channel depth:
gray: 8-bit
alpha: 1-bit
convert logo2gt.png -define png:color-type=6 logo2gt_t6.png
convert: Cannot write image with defined PNG:bit-depth or PNG:color-type. `logo2gt_t6.png' @ png.c/PNGErrorHandler/1455.
see
http://www.imagemagick.org/Usage/formats/#png_write where it says to use 6 for RGB Matte
Even this may not work correctly?
convert logo: -resize 50% -colorspace gray -depth 8 logo2g.png
convert logo2gt.png -define png:color-type=2 logo2g_t2.png
identify logo2g_t2.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 320x240+0+0
Resolution: 72x72
Print size: 4.44444x3.33333
Units: Undefined
Type: Grayscale
Base type: Grayscale
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
Channel depth:
gray: 8-bit
Shouldn't the type be truecolor and not grayscale?
But the class has been changed to Truecolor!
I am not sure what to expect?
Re: -type command not working
Posted: 2010-01-27T18:09:55-07:00
by gotskill10
Still doesn't work:
curl -O
http://s3.amazonaws.com/mixbook/4.png
convert 4.png -define png:color-type=2 5.png
convert 5.png -type TrueColor 6.png
identify -verbose 6.png | grep "Type"
>> Type: Bilevel
Anybody else want to take a crack at this?
Re: -type command not working
Posted: 2010-01-27T19:51:49-07:00
by magick
Glenn, the PNG maintainer says:
Their first try did not work because the image was grayscale. You have to prepare the image as mentioned in the "-define" documentation to be of a type that agrees with the requested output format. Use -type Truecolor to do that.
"identify" does not describe the input format, only the contents of the image. If it contains only black and white pixels, it's bilevel even if they are stored in the PNG file (or another format) as 16-bit RGB, 8-bit RGB, 8-bit GA, etc.
To find out what's really in the PNG file, use -debug coder or a 3rd-party app like pngcheck.
This works:
convert logo: -resize 50% -colorspace gray -transparent white logo2gt.png
convert logo2gt.png -type Truecolor -define png:color-type=6 logo2gt_t6.png
Re: -type command not working
Posted: 2010-01-27T20:20:57-07:00
by fmw42
This works:
convert logo: -resize 50% -colorspace gray -transparent white logo2gt.png
convert logo2gt.png -type Truecolor -define png:color-type=6 -debug coder logo2gt_t6.png
even doing this:
convert logo: -resize 50% -colorspace gray -transparent white logo2gt.png
convert logo2gt.png -
type TruecolorMatte -define png:color-type=6 logo2gt_t6.png
The type showing in identify is still grayscalematte and not truecolormatte.
So you say that identify is not adequate to really know? Is that correct? PNGCHECK is needed then?
Re: -type command not working
Posted: 2010-01-27T20:27:05-07:00
by gotskill10
My experience has been that I can't get this to work with JPG images either.
fmw42 wrote:This works:
convert logo: -resize 50% -colorspace gray -transparent white logo2gt.png
convert logo2gt.png -type Truecolor -define png:color-type=6 -debug coder logo2gt_t6.png
even doing this:
convert logo: -resize 50% -colorspace gray -transparent white logo2gt.png
convert logo2gt.png -
type TruecolorMatte -define png:color-type=6 logo2gt_t6.png
The type showing in identify is still grayscalematte and not truecolormatte.
So you say that identify is not adequate to really know? Is that correct? PNGCHECK is needed then?
Re: -type command not working
Posted: 2010-01-27T21:03:42-07:00
by fmw42
JPG does NOT support transparency and the special -define commands are for png only.
see
http://www.imagemagick.org/Usage/formats/#jpg for its own -define commands
Re: -type command not working
Posted: 2010-01-28T11:57:42-07:00
by magick
Use this command to report details about a PNG image:
- identify -verbose -debug coder -log %e file.png
Re: -type command not working
Posted: 2010-01-28T16:35:38-07:00
by gotskill10
This is another way to view the properties of the resulting image. Even with this, it describes the image as being Bilevel.
The core issue here is that the "-type" command is not working. According to the documentation:
Normally, when a format supports different subformats such as grayscale and truecolor, the encoder will try to choose an efficient subformat. The -type option can be used to overrride this behavior. For example, to prevent a JPEG from being written in grayscale format even though only gray pixels are present, use 'convert bird.png -type TrueColor bird.jpg'.
Back to my original example:
curl -O
http://s3.amazonaws.com/mixbook/4.png
convert 4.png -type TrueColor 5.png
identify -verbose 5.png | grep "Type" (OR identify -verbose -debug coder -log %e 5.png)
This returns the "Type" as "Bilevel" no matter how you analyze the image. According to the documentation, it should be returning "TrueColor". I'm severely baffled why this is. Is this just a bug I have to deal with? I've tried this on two different computer with two different versions of IM on each.
magick wrote:Use this command to report details about a PNG image:
- identify -verbose -debug coder -log %e file.png
Re: -type command not working
Posted: 2010-01-28T16:53:01-07:00
by magick
There is a patch in ImageMagick 6.5.9-1 Beta that should fix the problem you reported. You test it now if you download the release from
ftp://ftp.imagemagick.org/pub/ImageMagick/beta.
Re: -type command not working
Posted: 2010-01-28T19:03:40-07:00
by gotskill10
I tested it. It still does not work. Are you sure it's fixed. Here is the output from my console:
http://pastie.org/799836.
Any thoughts on how to fix this?
Re: -type command not working
Posted: 2010-01-29T06:37:46-07:00
by magick
The PNG developer says "tell 'em we patched "-define" not "-type." See the ChangeLog in the source distribution.
Re: -type command not working
Posted: 2010-01-29T13:22:20-07:00
by gotskill10
magick wrote:The PNG developer says "tell 'em we patched "-define" not "-type." See the ChangeLog in the source distribution.
This isn't working either:
$ convert --version
Version: ImageMagick 6.5.9-1 2010-01-28 Q8
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
$ curl -O
http://s3.amazonaws.com/mixbook/4.png
$
convert 4.png -define png:color-type=2 5.png
$ convert 5.png -type TrueColor 6.png
$ identify -verbose 6.png | grep "Type"
Type: Bilevel
What's next?