1

I am using gm for node. I would like know the equivalent Javascript of the ImageMagick CLI command:

convert /path/to/source.png -format "%@" info:-

This will output the trim data, resulting in something like:

2672x3579+1115+725

I initially assumed the gm equivalent would be:

gm('/path/to/source.png').identify('%@', (err, result) => {
  console.log(result)
})

But this just returns the source file size without trimming whitespace.

5000x5000+0+0

Colin Meinke
  • 173
  • 1
  • 1
  • 7

2 Answers2

2

Try it this way:

gm convert a.png -format "%@" info:-

Or this way:

gm convert a.png -trim -format "%w %h" info:-
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • Sorry. I don't speak JS - I was hoping that someone else might be able to help out with the other half of the answer if I provided the half I know. – Mark Setchell Jan 17 '17 at 10:03
1

I figured it out.

gm('/path/to/source.png')
  .in('-format', '%@')
  .write('info:-', (err, result) => {
    console.log(result)
  })

The writing to info:- was the aha moment.

Colin Meinke
  • 173
  • 1
  • 1
  • 7