-type command not working
-
- Posts: 17
- Joined: 2007-06-02T14:01:34-07:00
-type command not working
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.
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.
-
- Posts: 17
- Joined: 2007-06-02T14:01:34-07:00
Re: -type command not working
Can anyone try this and let me know if it works for them?
Re: -type command not working
Use -define png:color-type=2. See http://www.imagemagick.org/script/comma ... php#define about the PNG defines.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: -type command not working
I have tried this for a test, but it gives an error message. Am I doing something wrong?magick wrote:Use -define png:color-type=2. See http://www.imagemagick.org/script/comma ... php#define about the PNG defines.
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?
Last edited by fmw42 on 2010-01-27T18:28:28-07:00, edited 1 time in total.
-
- Posts: 17
- Joined: 2007-06-02T14:01:34-07:00
Re: -type command not working
Still doesn't work:magick wrote:Use -define png:color-type=2. See http://www.imagemagick.org/script/comma ... php#define about the PNG defines.
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: -type command not working
even doing this: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
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?
-
- Posts: 17
- Joined: 2007-06-02T14:01:34-07:00
Re: -type command not working
My experience has been that I can't get this to work with JPG images either.
fmw42 wrote:even doing this: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
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?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: -type command not working
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
see http://www.imagemagick.org/Usage/formats/#jpg for its own -define commands
Re: -type command not working
Use this command to report details about a PNG image:
- identify -verbose -debug coder -log %e file.png
-
- Posts: 17
- Joined: 2007-06-02T14:01:34-07:00
Re: -type command not working
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:
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.
The core issue here is that the "-type" command is not working. According to the documentation:
Back to my original example: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'.
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
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.
-
- Posts: 17
- Joined: 2007-06-02T14:01:34-07:00
Re: -type command not working
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.magick wrote: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.
Any thoughts on how to fix this?
Re: -type command not working
The PNG developer says "tell 'em we patched "-define" not "-type." See the ChangeLog in the source distribution.
-
- Posts: 17
- Joined: 2007-06-02T14:01:34-07:00
Re: -type command not working
This isn't working either:magick wrote:The PNG developer says "tell 'em we patched "-define" not "-type." See the ChangeLog in the source distribution.
$ 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?