Page 1 of 1

Need to Force "convert" to Produce Image Type DirectClass

Posted: 2011-08-08T12:52:08-07:00
by anyoneis
I am producing 16 tiles (.png) from a large image (.tif) by first transferring the image to an MPC and then using 16 separate "convert -crop" commands to create the tiles.

The tiles created by convert are usually image type DirectClass, but sometimes I will get one of the images in the set converting as image type PseudoClass.

I need these tiles to all be of the same image type. If convert allwed me to specify "-imagetype DirectClass" I would have a solution, but alas, it does not.

Any other ideas? I am using ImageMagick-6.7.1-Q8. The commands are:
identify "WRL 15 1A.tif[2]"
WRL 15 1A.tif[2] TIFF 57632x615 84 57632x61584+0+0 8-bit DirectClass 1.1209GB 0.062u 0:00.203
convert "WRL 15 1A.tif[2]" f:\imagemagick\image.mpc
convert "f:\imagemagick\image.mpc" -crop 14408x15396+0+0 +repage -scene 0 "e:\imagemagick\extract_png\WRL_15_1A_0.png"
convert "f:\imagemagick\image.mpc" -crop 14408x15396+14408+0 +repage -scene 0 "e:\imagemagick\extract_png\WRL_15_1A_1.png"
convert "f:\imagemagick\image.mpc" -crop 14408x15396+28816+0 +repage -scene 0 "e:\imagemagick\extract_png\WRL_15_1A_2.png"
...
Thanks,
David

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-08T15:20:40-07:00
by fmw42
try -type truecolor

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-16T10:51:35-07:00
by anyoneis
fmw42 wrote:try -type truecolor
Hi Fred. I tried that again, first before the input file and then just before the output file name. No change.

Thanks,
David

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-16T11:15:52-07:00
by fmw42
IM appears to be too smart and if it knows that the number of colors is 256 or less it makes the result pseudoclass. The only way I can see to override that would be to do some kind of processing that introduces more colors. But I am not an expert on this and hopefully the IM developers can be more informative.

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-18T17:38:33-07:00
by anthony
The PNG codec has a lot of special program options. It may not be responding to the -type setting as it should, when no special PNG defines are present.

See the special PNG coder defines in...
http://www.imagemagick.org/Usage/formats/#png_write
or in the header comments of the coder/png.c codec source.

I'll send Glen (the developer of the PNG codec) a copy of this message for his comment.

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-18T17:40:46-07:00
by fmw42
I tried using that with no success, i.e. -define png:color-type=2

For png:

convert logo: -type truecolor logo.png
identify -verbose logo.png
Image: logo.png
Format: PNG (Portable Network Graphics)
Class: PseudoClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: Undefined
Type: Palette


For miff:

convert logo: -type truecolor logo.miff
identify -verbose logo.miff
Image: logo.miff
Format: MIFF (Magick Image File Format)
Class: DirectClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: Undefined
Type: Palette
Base type: TrueColor

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-18T17:50:44-07:00
by glennrp
Try writing to PNG24:output.png
or if you know it's transparent, PNG32:output.png

What happened when you used -define png:colortype=2 ?

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-18T17:55:12-07:00
by fmw42
glennrp wrote:Try writing to PNG24:output.png
or if you know it's transparent, PNG32:output.png

What happened when you used -define png:colortype=2 ?
convert logo: -define png:colortype=2 logo2.png
identify -verbose logo2.png
Image: logo2.png
Format: PNG (Portable Network Graphics)
Class: PseudoClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: Undefined
Type: Palette


This seems to work with PNG24:

convert logo: -type truecolor PNG24:logo3.png
freds-mac-mini:~ fred$ idv logo3.png
Image: logo3.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: Undefined
Type: Palette

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-18T18:07:30-07:00
by glennrp
Try -define png:color-type=2

You omitted the hyphen in color-type

However, that didn't work for me. The decoder refused to do it, with
a warning.

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-18T18:22:18-07:00
by fmw42
sorry, I just copied your command from above, which did not have the hyphen and did not look it up properly


convert logo: -define png:color-type=2 logo4.png
identify -verbose logo4.png
Image: logo4.png
Format: PNG (Portable Network Graphics)
Class: PseudoClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: Undefined
Type: Palette

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-18T19:33:35-07:00
by glennrp
The -define PNG:color-type2 option should work now for PseudoClass input, SVN revision 4996, which will be IM-6.7.1-8 in a few days.

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-25T15:19:34-07:00
by anyoneis
I may be misunderstanding, but the problem I posted about was forcing convert to produce DirectClass. I am using the output of convert as input to another image processing utility. Just in case, I tried adding the define, as in:

Code: Select all

c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "\\silo\cds\CDS-CS\Programming\BPATH\Hudkins_WRL 15 1A.tif[9]" f:\imagemagick\image.mpc
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+0+0 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_00.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+114+0 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_01.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+228+0 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_02.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+342+0 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_03.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+0+122 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_04.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+114+122 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_05.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+228+122 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_06.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+342+122 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_07.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+0+244 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_08.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+114+244 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_09.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+228+244 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_10.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+342+244 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_11.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+0+366 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_12.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+114+366 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_13.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+228+366 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_14.png"
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+342+366 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_15.png"
But I still got mixed image types:

F:\_code\BPathImagePrep\BPathImagePrep\bin\x64\Debug>for %a in (e:\imagemagick\extract_png\Hudkins_WRL_15_1A_*.png) do @identify %a
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_00.png PNG 114x122 114x122+0+0 8-bit DirectClass 13.1KB 0.000u 0:00.001
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_01.png PNG 114x122 114x122+0+0 8-bit DirectClass 8.68KB 0.000u 0:00.001
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_02.png PNG 114x122 114x122+0+0 8-bit DirectClass 17.2KB 0.000u 0:00.001
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_03.png PNG 114x122 114x122+0+0 8-bit DirectClass 17.9KB 0.000u 0:00.000
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_04.png PNG 114x122 114x122+0+0 8-bit DirectClass 29.8KB 0.000u 0:00.001
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_05.png PNG 114x122 114x122+0+0 8-bit DirectClass 27.7KB 0.000u 0:00.000
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_06.png PNG 114x122 114x122+0+0 8-bit DirectClass 18.3KB 0.000u 0:00.001
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_07.png PNG 114x122 114x122+0+0 8-bit DirectClass 13KB 0.000u 0:00.001
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_08.png PNG 114x122 114x122+0+0 8-bit DirectClass 24.8KB 0.000u 0:00.000
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_09.png PNG 114x122 114x122+0+0 8-bit DirectClass 16.9KB 0.000u 0:00.000
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_10.png PNG 114x122 114x122+0+0 8-bit DirectClass 25.4KB 0.000u 0:00.001
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_11.png PNG 114x122 114x122+0+0 8-bit DirectClass 18.1KB 0.000u 0:00.000
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_12.png PNG 114x122 114x122+0+0 8-bit PseudoClass 115c 4.54KB 0.000u 0:00.000
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_13.png PNG 114x122 114x122+0+0 8-bit PseudoClass 166c 5.21KB 0.000u 0:00.000
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_14.png PNG 114x122 114x122+0+0 8-bit DirectClass 23KB 0.016u 0:00.001
e:\imagemagick\extract_png\Hudkins_WRL_15_1A_15.png PNG 114x122 114x122+0+0 8-bit DirectClass 9.14KB 0.000u 0:00.000

David

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-25T18:46:23-07:00
by fmw42
What version of IM did you use on your last tests and exactly what was the command line?

Did you try skipping the -define and just use PNG24: or PNG32: (if transparency) to preface the output.

In any case, if you are on the current version of IM and -define still fails, then you should post a link to one or all of those failing images so that Glenn can test with them.

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-26T08:41:34-07:00
by glennrp
anyoneis wrote:I may be misunderstanding, but the problem I posted about was forcing convert to produce DirectClass. I am using the output of convert as input to another image processing utility. Just in case, I tried adding the define, as in:

Code: Select all

c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "\\silo\cds\CDS-CS\Programming\BPATH\Hudkins_WRL 15 1A.tif[9]" f:\imagemagick\image.mpc
c:\Program Files (x86)\ImageMagick-6.7.1-Q8\convert "f:\imagemagick\image.mpc" -crop 114x122+0+0 +repage -scene 0 -define PNG:color-type2 "e:\imagemagick\extract_png\Hudkins_WRL_15_1A_00.png"
David[/quote]
It's PNG:color-type=2 not PNG:color-type2
Note the equals-sign.

Re: Need to Force "convert" to Produce Image Type DirectCla

Posted: 2011-08-26T09:34:36-07:00
by anyoneis
Good eye, mate! So it is! Problem solved.

Thanks All!

David