简体   繁体   中英

How to edit the exposure of an HDRI image using GraphicsMagick and Node.js?

I have ImageMagick installed with support for HDRI images. Using bash, the following command can be used to save the image with a different number of 'stops' (where stops is a measure of exposure):

stops=`convert xc: -format "%[fx:pow(2,-1)]"`
convert input.exr \
    -colorspace RGB \
    -function polynomial "$stops,0" \
    -gamma 1 \
    -colorspace sRGB \
    output-minus-one-stop.jpg

In order to do this Node.js, some translation is needed:

var stops = Math.pow(2, -1);
gm('input.exr').colorspace('RGB')
    .out(`function polynomial "${stops},0"`)
    .gamma(1, 1, 1)
    .colorspace('sRGB')
    .write('output-minus-one-stop.jpg', function(err){});

However I get the error:

Command failed: convert: unable to open image `function polynomial "0.25,0"': No such file or directory @ error/blob.c/OpenBlob/2702
convert: no decode delegate for this image format `25,0"' @ error/constitute.c/ReadImage/501

The error is happening because of this line:

.out(`function polynomial "${stops},0"`)

What's the correct way to format the out command in this example?

I don't speak node, but I am fairly familiar with ImageMagick.

The gm you have looks (to me) like GraphicsMagick rather than ImageMagick (the two are different) and I don't think GraphicsMagick has the -function polynomial .

Can you move to IM rather than GM? I may be wrong on either count - and am happy to be corrected if anyone knows better.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM