Page 1 of 1

-depth "max" please

Posted: 2014-01-18T20:15:44-07:00
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.

Re: -depth "max" please

Posted: 2014-01-21T12:46:55-07:00
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

Re: -depth "max" please

Posted: 2014-01-21T12:52:03-07:00
by snibgo
Ha! Yes, that seems to work. Thanks.

Re: -depth "max" please

Posted: 2014-01-21T13:20:13-07:00
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