-depth "max" please

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

-depth "max" please

Post by snibgo »

I work with Q16. I sometimes need to include "-depth 16" in a script to ensure I don't lose precision. I'd like my scripts to be portable, certainly in Q32 and possibly in Q8. So I don't want to specify a particular number of bits, but "give me all the bits you can".

I can do this in a script, of course, calling IM first to enquire the Q-number, then use that for the real work. But this is slow and awkward. I'd prefer a "-depthMax" option, or similar.

Thanks.
snibgo's IM pages: im.snibgo.com
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: -depth "max" please

Post by glennrp »

snibgo wrote:I work with Q16. I sometimes need to include "-depth 16" in a script to ensure I don't lose precision. I'd like my scripts to be portable, certainly in Q32 and possibly in Q8. So I don't want to specify a particular number of bits, but "give me all the bits you can".
I believe "+depth" is the same as your proposed "-depthMax". See code in wand/mogrify.c beginning around line 1284.
This feature isn't mentioned in the commandline documentation, but that's easily fixed.

Oops, looks like that won't always be true. wand/convert.c, wand/montage.c, and others just ignore "+depth", as far as I can tell.

Glenn
Last edited by glennrp on 2014-01-21T12:52:53-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -depth "max" please

Post by snibgo »

Ha! Yes, that seems to work. Thanks.
snibgo's IM pages: im.snibgo.com
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: -depth "max" please

Post by glennrp »

Doesn't work the way I expected.
  • glenn.rp> convert rose: +depth -compress none rose+dmax.ppm
    glenn.rp> ls -l rose+d.ppm
    -rw-rw-r-- 1 glennrp glennrp 58670 Jan 21 15:09 rose+dmax.ppm
    glenn.rp> head -4 rose+dmax.ppm
    P3
    70 46
    4294967295
    12336 12079 11565 12850 12336 11822 13878 12850 12079 14392 13107 11822
Notice the 4.29G depth value in the PPM file, that should have been 16k.
The pixel values do seem to have the correct range, though. Mogrify didn't work either:
  • glenn.rp> convert rose: rose.png
    glenn.rp> mogrify -format ppm +depth -compress none rose.png
    glenn.rp> head -4 rose.ppm
    P3
    70 46
    4294967295
    12336 12079 11565 12850 12336 11822 13878 12850 12079 14392 13107 11822
    glenn.rp> convert | head -1
    Version: ImageMagick 6.8.8-2 Q16 x86_64 2014-01-12 http://www.imagemagick.org
Post Reply