detect format type

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
wchang615

detect format type

Post by wchang615 »

Dear All,

Sorry to bother this list for a simple question:
are there any MagickCore functions to detect what graphic format
(.gif, .jpg, etc.) for a given file?

Thanks.

--Wo
wchang615

Re: detect format type

Post by wchang615 »

I think I found the answer myself: just just image->magic.

--Wo
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: detect format type

Post by magick »

If you just want to detect the format, use PingImage() instead of ReadImage(). PingImage() is lightweight.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: detect format type

Post by anthony »

The 'magick' part is also available (completely outside of IM) using the "file" command. IM itself does similar things in determining image format styles.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply