tags:

views:

291

answers:

3

So my host provides ImageMagick on the server, but no MagickWand or IMagick API for PHP. I can do operations with the PHP exec command to manipulate images. But that requires full path file names to work, and I want to pull my images from my MySQL database. Will I have to have pull them out of the database and put them to a file everytime I want to do this? Any recommendations?

A: 

If the only ImageMagick available to you can only operate on files (which is how I read your first sentence), then you will indeed have to make files from your MySQL blobs to use ImageMagick on them (and remember to clean things up afterwards). My recommendation might be to switch to a better hosting service, but I assume you have your reasons to stay with that one.

Alex Martelli
+3  A: 

One option is to run the imagemagick process using proc_open() and write/read to/from the created process' stdin/stdout.

To have imagemagick read from stdin, you just give a dash '-' as input file. Specify /dev/stdout as the output file. Your call to image magick should look something like:

convert -scale 150x100 - /dev/stdout

Use fwrite and fread on the pipes created by proc_open to write input to imagemagick and read output back.

I haven't tried it, but I guess this should work.

rodion
A: 

have you tried phMagick ?