PHP and Convert()

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
Galaxy_Stranger
Posts: 2
Joined: 2013-05-29T17:23:47-07:00
Authentication code: 6789

PHP and Convert()

Post by Galaxy_Stranger »

I'm writing a web-app in PHP that will take an image and stitch it together with another image to create a third image with both originals appearing side-by-side.

As I understand it, Imagemagick's Convert() provides the functionality I need. I've been going through PHPs Imagmagick functionality, but I'm having trouble finding a "convert" method or anything that would work.

What is the preferred method of performing this using PHP?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PHP and Convert()

Post by fmw42 »

Imagick is not well supported and uses different syntax than Imagemagick. I would suggest you just use PHP exec() and run Imagemagick normal command line syntax with convert.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: PHP and Convert()

Post by Bonzo »

I have a lot of Imagemagick and a few Imagick examples on my website

As fmw42 said I would go with the exec() method rather than Imagick although your code should be quite simple.

Code: Select all

<?php  
$cmd = "input1.jpg input2.jpg +append";  
exec("convert $cmd append_horiz.jpg"); 
 ?>  

Code: Select all

<?php  
$im = new Imagick(); 
$im->readImage('input1.jpg'); 
$im->readImage('input1.jpg'); 
$im->resetIterator(); 
$appended = $im->appendImages(FALSE); 
$appended->writeImage('appendImages.jpg');  
$appended->destroy(); 
 ?>  
Galaxy_Stranger
Posts: 2
Joined: 2013-05-29T17:23:47-07:00
Authentication code: 6789

Re: PHP and Convert()

Post by Galaxy_Stranger »

Well, if that's what I have to do I'll go for it.

It just seemed odd that there wasn't a built-in way of going about it.

Thanks!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: PHP and Convert()

Post by Bonzo »

Imagemagick is an external program that is not built into php so you can not just use convert. Although I believe version 7 may be built into future versions of php.
Post Reply