Running from command line using PHP

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
JAM3SoN

Running from command line using PHP

Post by JAM3SoN »

I've used phpthumb() for my thumbnail creations, but I decided to use only simple exec() command to covert images due to speed reasons. Everything works well but everytime I run exec(), php runs command line tool and black windows appears for a while. How can I get rid of this window? When using phpthumb(), it wasn't shown but I wasn't able to find it in source codes. Thanks for your help ;)
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Running from command line using PHP

Post by Bonzo »

That does not happen to me with php; what code are you using?

Also a lot of php and ImageMagick examples on my site.
JAM3SoN

Re: Running from command line using PHP

Post by JAM3SoN »

Dynamically generated from upload script:

ImageMagick\convert.exe upload/qnusup8mzv/s57h2lfa4r.jpg -write mpr:image +delete \( mpr:image -thumbnail 480 -write upload/qnusup8mzv/s57h2lfa4r_480.jpg \) ( mpr:image -thumbnail 250 -write upload/qnusup8mzv/s57h2lfa4r_250.jpg \) ( mpr:image -thumbnail 100 -write upload/qnusup8mzv/s57h2lfa4r_100.jpg \) ( mpr:image -thumbnail 64x64! -write upload/qnusup8mzv/s57h2lfa4r_64.jpg \)

This is in variable which is parameter of exec function.

This is quite fast for me, but is there any way how to speeden it up? when it is in MPR, does it need to be cleared or MPR is cleared automatically?

I am quite new to this, but this works. :P

Moreover, what is faster? Exec(or passthru, system) or using MagickWand or Imagick?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Running from command line using PHP

Post by Bonzo »

What happens if you use this:

Code: Select all

exec("convert upload/qnusup8mzv/s57h2lfa4r.jpg \( +clone -thumbnail 480 -write upload/qnusup8mzv/s57h2lfa4r_480.jpg +delete \) ( +clone -thumbnail 250 -write upload/qnusup8mzv/s57h2lfa4r_250.jpg +delete \) ( +clone -thumbnail 100 -write upload/qnusup8mzv/s57h2lfa4r_100.jpg +delete \) -thumbnail 64x64! upload/qnusup8mzv/s57h2lfa4r_64.jpg ");
Using Imagick or Magickwand should be fatser, exec and system are the same - system displays some results but exec does not. No idea about passthru
JAM3SoN

Re: Running from command line using PHP

Post by JAM3SoN »

When I start with convert only, it doesn't find appropriate convert.exe. I don't know how to set up PHP(probably) to work with it, maybe I should copy convert.exe to directory where executed script is... maybe? Are you sure using those libraries is faster? I need it to have that thumbnail query to be maximally optimized:P
JAM3SoN

Re: Running from command line using PHP

Post by JAM3SoN »

Bonzo wrote:What happens if you use this:

Code: Select all

exec("convert upload/qnusup8mzv/s57h2lfa4r.jpg \( +clone -thumbnail 480 -write upload/qnusup8mzv/s57h2lfa4r_480.jpg +delete \) ( +clone -thumbnail 250 -write upload/qnusup8mzv/s57h2lfa4r_250.jpg +delete \) ( +clone -thumbnail 100 -write upload/qnusup8mzv/s57h2lfa4r_100.jpg +delete \) -thumbnail 64x64! upload/qnusup8mzv/s57h2lfa4r_64.jpg ");
Using Imagick or Magickwand should be fatser, exec and system are the same - system displays some results but exec does not. No idea about passthru
I've made it work only with convert, but it still shows DOS dialog window with address C:\Windows\system32\cmd.exe and closes after execution.

Is it possible to pass into Imagick full convert query?
Post Reply