Before asking for help
Please read the instructions on how to debug phMagick, this will tell you what the error is.
Report a Bug
You can use the issue tracker to report bugs or suggest features
Ask for Help
You can always mail me, I’m glad to help No email is unanswered, but as you may unserstand those who came with a little donation will take priority and a little more efort
Paid Support
Paid support is also available for those who need someone with in depth knowledge of phMagick mail me your request and I will be glad to send you a quote
Hi,
How i create captcha from this.
Many thanks !
Nghia
Hi Nghia,
You can write the text with the fromString() function then apply it as a watermark with no transparency to a any background you like
Hello, I would like to generate images on the fly without having to save them to the disk. In fact I would like to write a PHP script returning an image to the browser (not HTML). Is this possible with phMagick?
Greetings from Luxembourg,
André
Helo André
phMagick runs from the command line, so it needs to generate files, you can however easily write a php script delete them x minutes after they where created
Hi
Thank you very much for your great utility!
When I used your resizeExactly function I found that it would not crop as I expected when using a source with e.g. aspect ratio 3/2 to a destination with a higher aspect ratio e.g. 4:2.
I thought it would then cut the pic at the top and the bottom, but it did not.
With a very small modification it works as a intend:
——————-
/**
* tries to resize an image to the exact size wile mantaining aspect ratio,
* the image will be croped to fit the measures
* @param $width
* @param $height
*/
function resizeExactly(phmagick $p , $width, $height){
//requires Crop plugin
//requires dimensions plugin
$p->requirePlugin(‘crop’);
$p->requirePlugin(‘info’);
list($w,$h) = $p->getInfo($p->getSource());
$desicion_height = $width * ($h/$w);
if($desicion_heightresize($w, $h)->crop($width, $height);
}
——————-
Kind regards, John
Here is the function again, as there were some losses because of wrong HTML-Tags:
—————–
/**
* tries to resize an image to the exact size wile mantaining aspect ratio,
* the image will be croped to fit the measures
* @param $width
* @param $height
*/
function resizeExactly(phmagick $p , $width, $height){
//requires Crop plugin
//requires dimensions plugin
$p->requirePlugin(‘crop’);
$p->requirePlugin(‘info’);
list($w,$h) = $p->getInfo($p->getSource());
$desicion_height = $width * ($h/$w);
if($desicion_height<$height){
$h = $height;
$w = 0;
}else{
$h = 0;
$w = $width;
}
$p->resize($w, $h)->crop($width, $height);
}
@John
Thanks, I will test it and include it in the next release
cheers
hi, sven
i tried to run your simplest sample script (the rotation):
rotate(45);
?>
i get:
Warning: include(phMagick.php) [function.include]: failed to open stream: No such file or directory in /home/alexan48/public_html/phmagick/testphmagick.php on line 2
my webhost tells me ImageMagick is installed. It’s path is:
ImageMagicK :- /usr/local/ImageMagick/bin
can you help?
many thanks
johny
@johny
The errors says it can not find a file named phMagick.php, your server file system is case sensitive so type the file name the same way it’s on your file system (ex: phmagick.php)
hi nuno
ok, now i’m not getting the error, just a blank page. is there a problem going from jpg to png?
note, the script comes from your ReadMe. thanks!
oh, i see, the result pngs are just saved into the directory! nice. now i have to figure out how to return them to the webpage.
i’m getting pdf conversions, great! problem, any pdf larger than about 200 Kb comes out scrambled. any idea why that might be? thanks! (feel free to delete my obsolete comments in this thread)
hi, i’ve read that your tool can be used to access the entire ImageMagick function library, through some sort of “exec” function. I cannot find instructions for this in your documentation. Can you help?
thanks much!
Well, you can not access all of ImageMagick right now
The exec function is a php function that executes systems calls, that’s what phMagick does, it builds a command line and then call the exec function to run the command
If you know the commands you can mail them to me and I will add them to phMagick
Hi, I’m trying to create a multi-page TIFF from a bunch of single page TIFF files
This works at the command line> convert p1.TIF p2.TIF p3.TIF multi3.TIF
Can this be scripted in PHP? Thanks!
I think you can, try
$phmagick->setSource(“p1.TIF p2.TIF p3.TIF”)
that should do the trick
hy the crop option is not ready ? is not active in documentation
Hi grek,
The crop function exists but it’s not documented
it would be great, if you want to contribute and document this function
cheers
Hi Sven,
I have used phMagick in the past with no problem. Today I am trying to get it working on a server which had to install ImageMagick. I cant seem to get it working though – I used your debug code and got the following:
phMagick: Error executing “convert -scale “200x>†-quality 80 -strip “source.jpg†“resized.jpg—
return code: 127
command output :â€sh: line 1: convert: command not foundâ€
Notice: exception ‘phMagickException’ in /home/noisepop/public_html/2010/dev/phmagick/phmagick.php:189 Stack trace: #0 /home/noisepop/public_html/2010/dev/phmagick/plugins/resize.php(46): phmagick->execute(’convert -scale …’) #1 /home/noisepop/public_html/2010/dev/phmagick/phmagick.php(205): phMagick_resize->resize(Object(phmagick), 200, 0) #2 [internal function]: phmagick->__call(Array, Array) #3 /home/noisepop/public_html/2010/dev/phmagick/index.php(6): phmagick->resize(’resize’, Array) #4 {main} in /home/noisepop/public_html/2010/dev/phmagick/phmagick.php on line 189
Array
(
[0] => Array
(
[cmd] => convert -scale “200x>†-quality 80 -strip “source.jpg†“resized.jpgâ€
[return] => 127
[output] => Array
(
[0] => sh: line 1: convert: command not found
)
)
)
1
Please advise – thank you very much.
PS – love to buy you a beer ;]
@Subal Smith
It seems that imagemagick is not in your system path (you must restart apache after installing imagemagick)
see this article for alternative ways to tell phMagick where imagemagick is : http://www.francodacosta.com/blog/phmagick/examples/error-convert-invalid-parameter
For the beer, you can go here : http://www.francodacosta.com/blog/about/buy-me-a-beer
How can I do multiple image re-sizes from same source file? I’ve tried this, but I get two same image outputs.
$x = new phmagick(“image.jpg”);
$x->setDestination(“outputlarge.jpg”)->resize(1600,1600);
$x->setDestination(“outputsmall.jpg”)->resize(640);
Hi, when i’m generating one image all works fine but when try to fill my gallery my Xampp crashes, without an error.
The images are generated thru the url like:
http://localhost/thumb/id/10.jpg
It seems like imagemagick or phmagick can’t have multiple instances at the same time. Any solution?
Tnx!
Just saw that you released a new version with the “resizeExactly” command. Works fine, but it seems, that no .PNG images are supported?! :-/
I just came across this and it seems great.
I am having some issues with it. I used debug you suggested and still get this. I restarted my apache and have tried various paths as described in the link above. Any help would be greatly appreciated.
Thanks
phMagick: Error executing “convert -scale “200x>” -quality 80 -strip “source.jpg” “resized.jpg”"
return code: 127
command output :”sh: convert: command not found”
Array
(
[0] => Array
(
[cmd] => convert -scale “200x>” -quality 80 -strip “source.jpg” “resized.jpg”
[return] => 127
[output] => Array
(
[0] => sh: convert: command not found
)
)
)
1
Hi,
I’m using phMagick to resize image, but i got some errors “rc: 7″ and “rc: 1″, what does errors mean? plz help me.
Thank so much.
@Christopher Tsanos
You need to have imagemagick installed and in your path
check http://www.francodacosta.com/blog/phmagick/examples/error-convert-invalid-parameter for information on how to manually specify the path to imagemagick
@Kith
probably imagemagick can’t find libpng
@Jan-Berend
you should use the phisical path for the images
have you checked your webserver logs (apache and php error logs) I’m sure you will find fullish information in there
@Bogdan Kharchenko
$x = new phmagick(â€image.jpgâ€);
$x->setDestination(â€outputlarge.jpgâ€)->resize(1600,1600);
$x->setSource(‘image.jpg’)
$x->setDestination(â€outputsmall.jpgâ€)->resize(640);
@Ting
please check http://www.francodacosta.com/blog/phmagick/examples/debugging-phmagick and download the latest version of phMagick the rc : 7 style of errors are from a very old version
Dear Sven,
I am running your script on a windows environment and I’m having the following issue when resizing an image:
An error occured:
phMagick: Error executing “convert -scale “600x>” -quality 80 -strip “../backend/images/albums/Tesr/07feb10_PVD_ARENA_MEL_5133.jpg” “../backend/images/albums/Tesr/07feb10_PVD_ARENA_MEL_5133.jpg”"
return code: 1
command output :”Access is denied.”
Notice: exception ‘phMagickException’ in C:\Inetpub\vhosts\freshevents.info\httpdocs\freshnewsite\backend\phmagick.php:189 Stack trace: #0 C:\Inetpub\vhosts\freshevents.info\httpdocs\freshnewsite\backend\plugins\resize.php(46): phmagick->execute(‘convert -scale …’) #1 [internal function]: phMagick_resize->resize(Object(phmagick), 600, 0) #2 C:\Inetpub\vhosts\freshevents.info\httpdocs\freshnewsite\backend\phmagick.php(205): call_user_func_array(Array, Array) #3 [internal function]: phmagick->__call(‘resize’, Array) #4 C:\Inetpub\vhosts\freshevents.info\httpdocs\freshnewsite\backend\uploadimages.php(76): phmagick->resize(600, 0) #5 {main} in C:\Inetpub\vhosts\freshevents.info\httpdocs\freshnewsite\backend\phmagick.php on line 189
Array
(
[0] => Array
(
[cmd] => convert -scale “600x>” -quality 80 -strip “../backend/images/albums/Tesr/07feb10_PVD_ARENA_MEL_5133.jpg” “../backend/images/albums/Tesr/07feb10_PVD_ARENA_MEL_5133.jpg”
[return] => 1
[output] => Array
(
[0] => Access is denied.
)
)
)
1
{“status”:”1″,”name”:”07feb10_PVD_ARENA_MEL_5133.jpg”}
any help please?
@Thomas Gatt
This seems like a permissions issue, does the web user user has access to to convert.exeor the files ?
Any useful information on the server logs?
Hello,
Is it possible to capture an html page with image magick and to generate a thumbnail on the fly ?
How would you to this ?
Best regards
Hello. After convert image from CR2 to JPG i saw darken image. What can be the reason for it ?
Hi, it is the best library of all that I used.
But I find bug into resizeExactly function, it returns empty.
please, change string:
$p->resize($w, $h)->crop($width, $height);
on:
return $p->resize($w, $h)->crop($width, $height);
Can you give any indication how fast phMagick is compared to using imagick? i.e. for thumbnailing and resizing for example
It should be a bit slower than imagick but much easier to use.
Imagick is a native php extension and phMagick does a system call
if you do a benchmark I would be very interested in the results