Home >Backend Development >PHP Tutorial >Code to merge images using php shell command

Code to merge images using php shell command

WBOY
WBOYOriginal
2016-07-29 08:45:401082browse

Copy the code The code is as follows:


#!/usr/local/bin/php -q
author:freemouse
// The following is the description.
print ("This program is used for merging 2 640x480 size .n");
print ("Picture and convert it into a 400x300 size .n");
print ("Need to specify to store the pre-synthesis picture (a.jpg, b.jpg) The default directory n");
print ("The generated image will be saved as c.jpgn");
//Default directory, edit it yourself^_^
$d="/home/freemouse/Desktop";
print ("The current directory is: $dn");
print (" Image a.jpg offset, 0-100: ");
$fp = fopen("php://stdin", "r");
$a = fgets($fp,255);
print (" Image b.jpg offset, 0-100: ");
$b = fgets($fp,255);
fclose($fp);
$ a=$a*3.2;
$a=floor($a);
$b=$b*3.2;
$b=floor($b);
// Scale the two images to 640x480 size
exec( "Scale to 640x480 - quality 95 " . $d . "/a.jpg");
exec("Scale to 640x480 - quality 95 " . $d . "/b.jpg");
$aa = "Convert- Quality 90 - Size 320x480+";
$ab = " " . $d . "/a.jpg";
$bb = " " . $d . "/b.jpg";
$ac = " " . $d . "/aa.jpg";
$cc = " " . $d . "/bb.jpg";
// Save the scaled a.jpg as aa.jpg
$yy = $aa . $a . $ ab . $ac;
print ("$yyn");
exec($yy);
// Save the scaled b.jpg as bb.jpg
$zz = $aa . $b . $bb . $cc ;
print ("$zzn");
exec($zz);
// Merge two pictures into c.jpg.
$adjoin = "Synthesis-quality 80 ";
$adjoin .= $d . "/ aa.jpg ";
$adjoin .= $d . "/bb.jpg ";
$adjoin .= $d . "/c.jpg";
print ("$adjoinn");
exec($adjoin) ;
//Resize c.jpg to 400x300 and add borders.
$edge="Scale to 400x300 -quality 75 -raise 4x4 -sharpen 1x1 " . $d . "/c.jpg";
print ("$edgen ");
exec($edge);
?>

The above has introduced the code for using the php shell command to merge images, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn