PDA

View Full Version : Qt ImageMagick "convert" fails



^NyAw^
19th December 2011, 11:08
Hi,

I'm using the code explained of the book "C++ GUI Programming with Qt4" chapter "Inter-Process Communication" that shows how to call ImageMagick "convert" application to convert an image file.
I have changed the parameters to use a call like "convert -density 300 a.pdf a.bmp", so the args will be "-density" "300" "a.pdf" and "a.bmp".
The output of QProcess tells that the parameter "300" is not valid.
I've also tryied to use it like "convert -enhance a.pdf a.bmp" like the book example and I get a similar result "parameter a.pdf is not valid".

Finally I want to tell that I used QProcess to call "identify -verbose a.pdf" and there is no problem and I can get the output of the process.

Anyone had a similar problem?
Thanks,

P.D.:
ImageMagick 6.7.3-8
Qt 4.6.1
Windows XP

marcvanriet
19th December 2011, 12:41
Hi,

Maybe you can specify the full path to the 'convert.exe' of imagemack, then you are sure that no other convert.exe is called.

Do the commands work when you execute them on the command line ?

The a.pdf file, is it in your project directory or in your .exe directory ? I believe the 'current directory' is the project directory, but I'm not 100% sure. When in doubt, I usually copy my test files everywhere to find out.

Best regards,
Marc

^NyAw^
19th December 2011, 12:58
Hi,



Maybe you can specify the full path to the 'convert.exe' of imagemack, then you are sure that no other convert.exe is called.

"convert.exe" is called, so don't need to specify the full path. I is on the PATH environment variable.



Do the commands work when you execute them on the command line ?

The comands called on the coomand line work perfectly



The a.pdf file, is it in your project directory or in your .exe directory ? I believe the 'current directory' is the project directory, but I'm not 100% sure. When in doubt, I usually copy my test files everywhere to find out.

The file is located in the correct folder. Think on that "convert.exe" says that the parameter is not valid, not that it can't find the file.

Thanks,

Added after 6 minutes:

Hi,

It seems that I found what is happening.
QProcess really calls "convert.exe" that is a Windows system application instead of "convert.exe" from ImageMagick.
What I really don't understand is why QProcess don't use the same system environment variables that the command line have.

d_stranz
19th December 2011, 16:57
QProcess really calls "convert.exe" that is a Windows system application instead of "convert.exe" from ImageMagick.
What I really don't understand is why QProcess don't use the same system environment variables that the command line have.

It almost certainly is using the same environment variables, but probably the Windows system directory is higher in priority on the system path than the ImageMagick directory. When you give an unqualified filename as a command line argument in a DOS window, it will search the current directory first for the matching exe; QProcess probably searches $PATH instead.

^NyAw^
19th December 2011, 17:28
Hi,



It almost certainly is using the same environment variables, but probably the Windows system directory is higher in priority on the system path than the ImageMagick directory. When you give an unqualified filename as a command line argument in a DOS window, it will search the current directory first for the matching exe; QProcess probably searches $PATH instead.


The application directory does not contain ImageMagick exec files. ImageMagick is into "C:\Program Files\ImageMagick6.7.3-8" and PATH variable contains first the ImageMagick bin folder and then the "windows\system32" folder, so I think that firstly it will search on "C:\Program Files\ImageMagick6.7.3-8" folder(this is the normal behaviour on the command line console).

Thanks,

marcvanriet
20th December 2011, 00:46
QProcess really calls "convert.exe" that is a Windows system application instead of "convert.exe" from ImageMagick.

Don't say I didn't tell you ;)