Reading out image size of vector files with ImageMagick
Posted: 2007-01-26T09:40:53-07:00
Hello everybody,
I was reading through the forum but I couldn't find any clue how I could get ImageMagick just returning image infos to a php variable.
My aim is finding out the image size of vector files, lets say its 400x600px. Depending on that, my next action would be php calculating the resize values. Then i would call IM again to do the actual resizing.
Something like that:
Anybody an idea? Would be great!
I was reading through the forum but I couldn't find any clue how I could get ImageMagick just returning image infos to a php variable.
My aim is finding out the image size of vector files, lets say its 400x600px. Depending on that, my next action would be php calculating the resize values. Then i would call IM again to do the actual resizing.
Something like that:
Code: Select all
$cmd = MAGICK_HOME."convert -identify verbose ".$sourcefile;
exec("$cmd");
# Here I need to evaluate the result from the IM call, I have no idea how to read this and put it into a variable
...
$newheight = #based on the IM result
...
$cmd2 = MAGICK_HOME."convert -sample ".$newheight." ".$sourcefile." ".$targetfile;
exec("$cmd2");