mardi 24 février 2015

combine resize and crop and thum and water mark on image

every user want upload 100 tif image.


and i should


1.convert tif to jpg


2.resize image to xx


3.crop image to 200X


4.set text watermark


PHP



move_uploaded_file($image_temp,$destination_folder.$image_name);

$image_name_only = strtolower($image_info["filename"]);

$name=$destination_folder.$image_name_only.".jpg";
$thumb=$destination_folder."thumb_".$image_name_only.".jpg";
$exec = '"C:\Program Files\ImageMagick-6.9.0-Q16\convert.exe" '.$destination_folder.$image_name. ' '.$name.' 2>&1';
exec($exec, $exec_output, $exec_retval);

$exec = '"C:\Program Files\ImageMagick-6.9.0-Q16\convert.exe" '.$name. ' -resize 1024x '.$name;
exec($exec, $exec_output, $exec_retval);

$exec = '"C:\Program Files\ImageMagick-6.9.0-Q16\convert.exe" '.$name. ' -thumbnail 200x200! '.$thumb;
exec($exec, $exec_output, $exec_retval);

$exec = '"C:\Program Files\ImageMagick-6.9.0-Q16\convert.exe" '.$name. " -background White label:ش.پ12355 -append ".$name;
exec($exec, $exec_output, $exec_retval);


this code worked but for every image give 1 second time and for 100 image ==>100 second!!!


Question:how can combile 4(convert,resize,crop,watermark) step to 1 step for reduce convert time?


How I can speed this up?


Aucun commentaire:

Enregistrer un commentaire