我正在使用 PHP gd 扩展图像画布:
$newimage = imagecreatetruecolor($imageWidth + 840, $imageHeight);
$color = imagecolorallocate($newimage, 0, 0, 0);
imagefill($newimage, 0, 0, $color);
imagecopy($newimage, $image, 0, 0, 0, 0, $imageWidth, $imageHeight);
//get extension of the cropped image
$ext = end(explode('.' , $imageName));
//timestamp it
$timestamp = time();
//rename the new image
$fileName = rand() . $timestamp . '.' . $ext;
//unlink old image
unlink($src);
//update the DB with new imagename
$update = array('update' => $this->image->update($imageID, $fileName));
//Set the path for the image
$path = 'data/gallery/' . $galleryID . '/images/album/' . $fileName;
//create the cropped image
imagejpeg($newimage,$path,$jpeg_quality);
这按预期工作,画布向右扩展了 840 像素。我想做的是将画布向左扩展 840 像素。不知道如何做到这一点。
谢谢您的帮助。