aheckmann / gm

GraphicsMagick for node
http://aheckmann.github.com/gm/
6.95k stars 615 forks source link

Non-image operations with -list #823

Open chris-maclean opened 3 years ago

chris-maclean commented 3 years ago

GraphicsMagick has some commands that do not operate on files, but return information about its operation. I see several such commands in this section of the GraphicsMagick documentation:

http://www.graphicsmagick.org/GraphicsMagick.html#details-list

gm supports these operations if the user understands how the underlying command will be built given chained arguments, but it's unintuitive to use. For example, to get the list of formats supported by GraphicsMagick with:

convert -list format

the gm user would have to call

gm('format').command('convert').in('-list').toBuffer((err, data) => console.log(data.toString('utf8'));)

This is pretty good except for the use of gm('format'). I find this to be a confusing invocation since the argument to the constructor is usually a file path or Buffer. This command takes advantage of the fact that "format" appears in the location that the filename would appear, if it were a file. It would also be really confusing if a file named format was in the current working directory.

Would it be possible to support these -list functions in some kind of utilities export, or maybe with a different, no-argument constructor? Is there already support for something like this, and I've just missed it? I will volunteer myself to add such functions if the owners of the project think they're necessary.