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

Code to merge images using php shell command_PHP tutorial

WBOY
Release: 2016-07-21 15:28:02
Original
1074 people have browsed it

Copy code The code is as follows:

#!/usr/local/bin/php -q
author:freemouse
// Here are the instructions.
print ("This program is used to merge two 640x480 .n");
print ("Pictures and convert them into one 400x300 size n");
print ("You need to specify the default directory n to store the pre-synthesised images (a.jpg, b.jpg)");
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 ("picture 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 the 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);

// Adjust c.jpg to 400x300 size and add a border.
$edge=" scale to 400x300 -quality 75 -raise 4x4 -sharpen 1x1 " . $d . "/c.jpg";
print ("$edgen");
exec($edge);

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323658.htmlTechArticleCopy the code as follows: #!/usr/local/bin/php -q author:freemouse ?php // The following is the description. print ("This program is used to merge 2 640x480 size .n"); print ("Pictures and convert them...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template