使用php shell命令合并图片的代码_PHP
Jun 01, 2016 pm 12:15 PM#!/usr/local/bin/php -q
author:freemouse
// 下面是说明.
print ("本程序用于合并2张 640x480大小的.\n");
print ("图片,并将其转化为一张 400x300 大小的图片\n");
print ("需要指定存放合成前图片(a.jpg,b.jpg)的默认目录\n");
print ("生成的图片将会保存为c.jpg\n");
//默认目录,自己编辑吧^_^
$d="/home/freemouse/Desktop";
print ("当前目录为: $d\n");
print (" 图片 a.jpg 偏移, 0-100: ");
$fp = fopen("php://stdin", "r");
$a = fgets($fp,255);
print (" 图片 b.jpg 偏移, 0-100: ");
$b = fgets($fp,255);
fclose($fp);
$a=$a*3.2;
$a=floor($a);
$b=$b*3.2;
$b=floor($b);
// 将两张图片缩放至 640x480 尺寸
exec("缩放至 640x480 -质量 95 " . $d . "/a.jpg");
exec("缩放至 640x480 -质量 95 " . $d . "/b.jpg");
$aa = "转换 -质量 90 -尺寸 320x480+";
$ab = " " . $d . "/a.jpg";
$bb = " " . $d . "/b.jpg";
$ac = " " . $d . "/aa.jpg";
$cc = " " . $d . "/bb.jpg";
// 缩放后的 a.jpg 另存为 aa.jpg
$yy = $aa . $a . $ab . $ac;
print ("$yy\n");
exec($yy);
// 缩放后的 b.jpg 另存为 bb.jpg
$zz = $aa . $b . $bb . $cc;
print ("$zz\n");
exec($zz);
// 合并两张图片为 c.jpg.
$adjoin = "合成 -质量 80 ";
$adjoin .= $d . "/aa.jpg ";
$adjoin .= $d . "/bb.jpg ";
$adjoin .= $d . "/c.jpg";
print ("$adjoin\n");
exec($adjoin);
// 调整 c.jpg 至 400x300 尺寸 并添加边框.
$edge="缩放至 400x300 -质量 75 -raise 4x4 -sharpen 1x1 " . $d . "/c.jpg";
print ("$edge\n");
exec($edge);
?>

Article chaud

Outils chauds Tags

Article chaud

Tags d'article chaud

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Sujets chauds

Comment installer Classic Shell sur Windows 11 ?
![Explorer.exe ne démarre pas au démarrage du système [Réparer]](https://img.php.cn/upload/article/000/887/227/168575230155539.png?x-oss-process=image/resize,m_fill,h_207,w_330)
Explorer.exe ne démarre pas au démarrage du système [Réparer]

Le déploiement PowerShell échoue avec le problème HRESULT 0x80073D02 résolu

Comment supprimer rapidement la ligne à la fin d'un fichier sous Linux

Différentes façons d'exécuter des fichiers de script shell sous Windows

Super hardcore ! 11 exemples de scripts Python et Shell très pratiques !

Voici les correctifs pour le problème de non-fonctionnement d'Open Shell Windows 11

Comment installer Open Shell pour restaurer le menu Démarrer classique sur Windows 11
