Score:2

How can I use the `identify` command to find out *only* the file type?

cn flag

I want to use the identify command (from ImageMagick) to determine a file's type.

The sample command

identify -quiet 'Sample File.gif'

will list several lines. Is there a short and simple way to obtain just the string GIF?

user10489 avatar
in flag
The `file` command is more versatile than `identify` but is even more noisy.
FedKad avatar
cn flag
The `file --extension -b 'Sample File.jpg'` command will return `jpeg/jpg/jpe/jfif`. Whereas I want a _single_ `jpeg` output.
user10489 avatar
in flag
I did say it is noisy.
Score:3
hr flag

You can use the %m percent escape to get just the file magic:

identify -quiet -format '%m\n' 'Sample File.gif'
FedKad avatar
cn flag
Thanks. I think that the _ImageMagick_ tools are so powerful, but also very little known and documented! :)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.