Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "Invalid Parameter" fom ImageMagick convert on Windows

I am trying to convert a PDF document into a PNG file using ImageMagick command line tools from a ASP.NET website. I create a new shell process and ahve it execute the following command:

convert -density 96x96 "[FileNameAndPath].pdf" "[FileNameAndPath].png" 

This runs well when testing the website on my local machine with the ASP.NET Develeopment Server of VS and the command also works well when manually entered into the shell. When running from the programatically created shell in ASP.NET there is the following error message:

Invalid Parameter - 96x96 

Does anybody know why that happens and what to do?

I have tested the command while being logged in on the server via RDP with a different user account than the ASP.NET process. I have used exactly the same ImageMagick and Ghostscript installation files as on my local machine and have activated adding the ImageMagick installation path to the enironment variables during installing. The server has not been rebooted since than.

like image 992
rs. Avatar asked Jun 17 '10 08:06

rs.


People also ask

How do I run ImageMagick on Windows?

You have 2 choices. 1) Use the full path every time you run ImageMagick, i.e. something like "C:\Programs\Image Magick\convert" or 2) Go to Settings -> System -> Advanced -> Environment Variables and click Edit and add the directory in to the start of your PATH.

What is ImageMagick library?

ImageMagick, invoked from the command line as magick , is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images. Created in 1987 by John Cristy, it can read and write over 200 image file formats.

What can you do with ImageMagick?

ImageMagick can resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.


1 Answers

convert is also the name of a windows executable which converts FAT filesystem to NTFS. When you do not specify the full path of an executable, quote:

...the system first searches the current working directory and then searches the path environment variable, examining each directory from left to right, looking for an executable filename that matches the command name given.

"C:\Windows\System32" is generally present in the beginning of %PATH% variable, causing the Windows convert utility to launch, which fails with "Invalid Parameter" error as expected.

Try specifying the full path of the ImageMagick's convert.exe like so:

"C:\Program Files\ImageMagick\convert.exe" -density 96x96 "path_and_filename.pdf" "path_and_filename.png" 
like image 73
Salman A Avatar answered Oct 26 '22 23:10

Salman A