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 );
?>