I have uploaded a number of images with different formats to a folder on my server. Using ImageMagick I want to convert them and replace them to JPG.
This is my code:
<?php
try
{
/*** the image file ***/
$image = 'temp_images/*.*';
/*** a new imagick object ***/
$im = new Imagick();
/*** ping the image ***/
$im->pingImage($image);
/*** read the image into the object ***/
$im->readImage( $image );
/**** convert to png ***/
$im->setImageFormat( "jpg" );
/*** write image to disk ***/
$im->writeImage( 'temp_images/input/*.jpg' );
echo 'Image Converted';
}
catch(Exception $e)
{
echo $e->getMessage();
}
?>
When I specify a particular image it converts it, when I replace say abc.gif
to *.*
I get the following error.
'unable to open image
temp_images/input/*.*
: No such file or directory @ error/blob.c/OpenBlob/2638'
In the documentation I read that I can use mogrify but I do not know who to insert comand line into PHP.