Code for merging images using the phpshell command

Source: Internet
Author: User
Php can be used not only in the web environment, but also in a very good shell. the following code demonstrates how to use php to merge images in the shell. The code is as follows:


#! /Usr/local/bin/php-q
Author: freemouse
// The description is as follows.
Print ("This program is used to merge two. \ n records of 640xxsize ");
Print ("image, and convert it to a 400x300 Image ");
Print ("default directory \ n ");
Print ("the generated image will be saved as c.jpg \ n ");

// Default directory. edit it by yourself. ^_^
$ D = "/home/freemouse/Desktop ";
Print ("current directory: $ d \ n ");

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 ($ );
$ B = $ B * 3.2;
$ B = floor ($ B );

// Scale two images to 640x480
Exec ("zoom to 640x480-quality 95". $ d. "/a.jpg ");
Exec ("zoom to 640x480-quality 95". $ d. "/B .jpg ");

$ Aa = "conversion-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 file as aa.jpg
$ Yy = $ aa. $ a. $ AB. $ ac;
Print ("$ yy \ n ");
Exec ($ yy );

// Save the scaled B .jpg file as bb.jpg
$ Zz = $ aa. $ B. $ bb. $ cc;
Print ("$ zz \ n ");
Exec ($ zz );

// Merge the two images into c.jpg.
$ Adjoin = "synthesis-quality 80 ";
$ Adjoin. = $ d. "/aa.jpg ";
$ Adjoin. = $ d. "/bb.jpg ";
$ Adjoin. = $ d. "/c.jpg ";
Print ("$ adjoin \ n ");
Exec ($ adjoin );

// Adjust c.jpg to 400x300 and add a border.
$ Edge = "zoom to 400x300-quality 75-raise 4x4-sharpen 1x1". $ d. "/c.jpg ";
Print ("$ edge \ n ");
Exec ($ edge );

?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.