Search code examples
node.jsimagemagickgraphicsmagick

Is there any format string to read Caption[2,120] data directly form a GraphicsMagick object?


I didn't find anything in the GraphicsMagick doc about reading the caption under the Profiles object data so I don't know if it's possible at all. Any suggestion?

This is how I'm able to retrieve the EXIF data from the gm object.

gm(dir + '/image.jpg').identify('%[EXIF:*]', function (err, info) {
    console.log(info);
});

Solution

  • The Caption[2, 120] tag is part of the IPTC spec, not EXIF. With ImageMagick, the IPTC is a little different, and follows the following format.

    %[IPTC:dataset:record]
    

    So for Caption, the dataset is 2, and the record is 120.

    %[IPTC:2:120]
    

    I don't know GraphicsMagick for Node, but this should work.

    gm(dir + '/image.jpg').identify('%[IPTC:2:120]', function (err, info) {
        console.log(info);
    });