Page 1 of 1

Limit input format for convert

Posted: 2016-05-07T10:12:48-07:00
by BlueDude
Hi,
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?

Re: Limit input format for convert

Posted: 2016-05-07T16:40:57-07:00
by fmw42
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 http://www.imagemagick.org/script/escape.php

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

Re: Limit input format for convert

Posted: 2016-05-07T18:47:56-07:00
by magick
See https://www.imagemagick.org/discourse-s ... =4&t=29588. You can disable all formats in the policy except JPEG. You can also delete the coder modules, except for JPEG, miff.so, png.so, tiff.so, etc.