これが私の現在のコードです:
define('IMG_WIDTH', (isset ($_GET['width'])) ? (int) $_GET['width'] : 99);
define('IMG_HEIGHT', (isset ($_GET['height'])) ? (int) $_GET['height'] : 75);
$image = imagecreatefromjpeg($_GET['image']);
$origWidth = imagesx($image);
$origHeight = imagesy($image);
$croppedThumb = imagecreatetruecolor(IMG_WIDTH, IMG_HEIGHT);
if ($origWidth > $origHeight)
{
$leftOffset = ($origWidth - $origHeight) / 2;
imagecopyresampled($croppedThumb, $image, 0, 0, $leftOffset, 0, IMG_WIDTH, IMG_HEIGHT, $origHeight, $origHeight);
}
else
{
$topOffset = ($origHeight - $origWidth) / 2;
imagecopyresampled($croppedThumb, $image, 0, 0, 0, $topOffset, IMG_WIDTH, IMG_HEIGHT, $origWidth, $origWidth);
}
基本的に、画像を取得し、サイズを変更してサムネイルを作成します。それは非常にうまく機能します。今やりたいことは、右下隅に透かしを追加することです。これに使用される関数を見てきましたimagecopymerge...ただし、リサンプリングされた画像をソースとして提供することはできないようです。
既に変更された画像に透かしを追加するにはどうすればよいですか? :/
画像を /tmp に保存し、透かしを追加したら unlink() することを考えましたが、それは少し混乱しているようです...