1

I'm invoking ImageMagick's convert.exe with the following python command:

os.system("convert -compress group4 %s -type bilevel -monochrome %s -alpha off" % (imagefilename,imagefilename.replace(ext1,ext2)))

Prior to adding "-alpha off" there were no errors, but the output image showed up as black and bright green instead of black and white. After adding it, the output images display correctly, but every time an image is converted an error is output:

.tifconvert.exe: missing an image filename `off' @ error/convert.c/ConvertImageCommand/3065

Is there a way to suppress this error, since it slows down run time and makes a mess in the command prompt window? I tried moving the -alpha off tag to before the file name, but then the images show up as green again in the image viewer.

5
  • 1
    Use the call() function in the subprocess module instead of os.system() and redirect stdout and/or stderr to os.devnull.
    – martineau
    Feb 26, 2015 at 18:16
  • From the ImageMagick documentation it looks like you should be using -alpha Off.
    – martineau
    Feb 26, 2015 at 18:24
  • Add a space after -alpha off. Feb 27, 2015 at 10:13
  • Even with -alpha off there is an error message. I am using PHP on Ubuntu. Error: convert-im6.q16: missing an image filename /srv/tmp/phpuNz7N2_preview.jpg @ error/convert.c/ConvertImageCommand/3255. - Anyone has another idea?
    – Avatar
    May 17, 2022 at 10:24
  • Update: The solution was to remove -write from the convert command. Now it works.
    – Avatar
    May 17, 2022 at 10:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.