I'd like to check for corrupted jpeg images and so far, straight in the command line I can use identify image.jpg
which outputs:
image.jpg JPEG 1920x1200 1920x1200+0+0 8-bit sRGB 65.5KB 0.000u 0:00.009
identify: Premature end of JPEG file `image.jpg' @ warning/jpeg.c/JPEGWarningHandler/352.
identify: Corrupt JPEG data: premature end of data segment `image.jpg' @ warning/jpeg.c/JPEGWarningHandler/352.
or gm identify image.jpg
which outputs:
image.jpg JPEG 1920x1200+0+0 DirectClass 8-bit 64.0Ki 0.000u 0:01
gm identify: Corrupt JPEG data: premature end of data segment (image.jpg).
gm identify: Corrupt JPEG data: premature end of data segment (image.jpg).
It would be nice if I can use the gm package to get the corrupt JPEG data too. Simply using identify()
outputs a lot of data, but nothing about corrupt data
gm('image.jpg')
.identify('%C',function (err, data) {
if (!err) console.log(data)
else console.error(err)
});
I've noticed this note in the readme:
If gm does not supply you with a method you need or does not work as you'd like, you can simply use gm().in() or gm().out() to set your own arguments.
I've tried something like this:
gm()
.command("identify")
.in('image.jpg');
but I get no output so I'm probably doing it wrong.
I've also tried node-cmd:
cmd.get(
'gm identify image.jpg',
function(data){
console.log('output: ',data)
}
);
but I only see the first line of the output.
What's the clean/recommended way of getting the multiline output from identify
via gm
package ? Otherwise, what's a node elegant solution to reading the full output of the identify command.
via George Profenza
No comments:
Post a Comment