Page 1 of 1

"convert" changes bitdepth

Posted: 2008-04-10T12:11:00-07:00
by naoliv
Hi!

From http://bugs.debian.org/472699, the user is saying that with ImageMagick version 6.2.4-5, he converts a 8-bit JPEG to PNG, and he gets a 8-bit too PNG.
But with newer versions (including the latest beta version 6.4.0-5, tested here), he gets a 16-bit PNG file.

Using "-depth 8" works, but shouldn't convert keep the same bit depth when converting, unless -depth is specified?

Thank you!

Re: "convert" changes bitdepth

Posted: 2008-04-10T12:18:29-07:00
by magick
Not a bug. ImageMagick, by design, promotes the image depth to the QuantumDepth (e.g. Q16) whenever pixels are modified. As you mentioned, the solution is to use the -depth command line option to set the desired depth. The user is encouraged to post an enhancement request to maintain the color depth of the original image, however, that would require a new option so that existing scripts do not break (e.g. convert image.png -depth original image.tif).

Re: "convert" changes bitdepth

Posted: 2008-04-10T12:30:50-07:00
by naoliv
Right.
Where can users send enhancement requests, please?

Thank you again!

Re: "convert" changes bitdepth

Posted: 2008-04-10T12:46:24-07:00
by magick
We have already added your enhancement request to our to-do list. We currently do not have an ETA but its simply to implement so we should have something in short order (i.e. a few weeks / a few months).

Re: "convert" changes bitdepth

Posted: 2008-12-21T14:25:16-07:00
by broucaries
I suppose this was fixed by :
2008-08-27 6.4.3-6 Cristy <quetzlzacatenango@image...>
Set image depth when -depth is fired.

Regards

Bastien

Re: "convert" changes bitdepth

Posted: 2009-01-02T11:13:09-07:00
by broucaries
Hi,

Could you either ACK or NACK that this was fixed by cited commit?

Regards

Bastien

Re: "convert" changes bitdepth

Posted: 2009-01-02T13:17:55-07:00
by magick
Not sure what you are asking for. The default behavior of ImageMagick is to increase the image depth if any pixels are modified. This makes sense to us because an 8-bit image when resized, for example, goes from 8-bits to 16-bits (assuming IM Q16) because of the blended colors. To force 8-bit output, simply add -depth 8 to the command line:
  • convert 8-bit.jpg 8-bit.png // output is 8-bit because no pixels were modified
    convert 8-bit.jpg -resize 50% 16-bit.png // output is 16-bit because IM is Q16 and the resize introduced blended colors
    convert 8-bit.jpg -resize 50% -depth 8 8-bit.png // output is 8-bit because we asked for 8-bit with -depth
Therefore we do not consider increasing the image depth a bug. Given the above discussion, how can we help?

Re: "convert" changes bitdepth

Posted: 2009-01-03T10:46:06-07:00
by broucaries
Thank you for your answer, I supposed it was fixed by the commit mentionned above.

Will maintain as a whislist item in our BTS with your answer copied.

Thank you for your time.

Regards

Bastien

Re: "convert" changes bitdepth

Posted: 2009-03-27T10:35:24-07:00
by Axaes
EDIT: Please ignore this post, I just discovered my mistake.

Aloha,

I apologize for raising this thread from the dead, but I need help how to place the depth command. I crop a master image into tiles, the tiles need to be 8bit for opensimulator.

The crop command for an 768pixel image into 9 tiles I use is:

convert -crop 256x256 me.png minime.png

Where do I add the 8bit depth command here so the minimi-tiles come out as 8bit?

Or, as an alternative, how do I convert a folder of tiles into 8bit in a separate step?

Re: "convert" changes bitdepth

Posted: 2009-03-27T11:03:21-07:00
by fmw42
Axaes wrote:EDIT: Please ignore this post, I just discovered my mistake.

Aloha,

I apologize for raising this thread from the dead, but I need help how to place the depth command. I crop a master image into tiles, the tiles need to be 8bit for opensimulator.

The crop command for an 768pixel image into 9 tiles I use is:

convert -crop 256x256 me.png minime.png

Where do I add the 8bit depth command here so the minimi-tiles come out as 8bit?

Or, as an alternative, how do I convert a folder of tiles into 8bit in a separate step?

convert me.png -crop 256x256 -depth 8 +repage minime.png

see
http://www.imagemagick.org/Usage/basics/#cmdline

+repage is needed to remove the larger virtual canvas whenever you nominally use -crop

To process a folder, use mogrify in place of convert.

See
http://www.imagemagick.org/Usage/basics/#mogrify

Re: "convert" changes bitdepth

Posted: 2009-03-28T14:38:18-07:00
by Axaes
I was using that command as suggested, apart from the repage addition, hence the confusion. However I found the error:

My problem was that the master image needed to be exported in L3DT as 8 bit png as well. If that option is not _explicitly_ selected in that application, the master image png output would be 16bit, which oddly resulted in 24bit tiles *with* the 8 bit command.

Normally I wouldn't even notice such things, but opensimulator refuses anything above 8 bit relating to terraforms. My solution was to set the export standard of L3DT (which I'm using under Wine) for png's at 8 bit. This then has the desired result of the tiles being 8bit as well.

Why the IM turns a 16 bit into 24 bit image with the 8bit command included is beyond my technical understanding, luckily L3DT has the option to export png's as 8 bit.

Re: "convert" changes bitdepth

Posted: 2009-03-28T14:46:56-07:00
by fmw42