Limit input format for convert

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
Posts: 1
Joined: 2016-05-07T10:07:54-07:00
Authentication code: 1151

Limit input format for convert

Post by BlueDude » 2016-05-07T10:12:48-07:00

is it possible to force or limit the input format(s) for the console command convert?
For example only allow JPEG files and if its not a JPEG file don't do anything.
Does it make sense to do that?

User avatar
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Limit input format for convert

Post by fmw42 » 2016-05-07T16:40:57-07:00

I think that is something best left to your server or interface software to avoid uploading or passing Imagemagick the offending formats.

In Im, you can disable some of the delegate libraries, such as PNG and TIFF and PDF (ghostscript), but GIF is internal and so probably cannot be disabled. I do not know about PSD. Perhaps the delegates.xml file can be modified to restrict use, but I would not know how to do that.

Alternately, you can write a simple script to check the image format and if not JPG, then do not call convert. That is the simplest approach, but the code depends upon your platform. See the string format "%m" at

Please always provide your IM version and platform, when asking questions on this forum, since syntax and scripting may differ.

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

Re: Limit input format for convert

Post by magick » 2016-05-07T18:47:56-07:00

See ... =4&t=29588. You can disable all formats in the policy except JPEG. You can also delete the coder modules, except for JPEG,,,, etc.

Post Reply