I am extending an image canvas with 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);
This works as expected, the canvas is extended to the right 840 pixels. What I would like to be able to do is extend the canvas to the left 840 pixels. Not sure how to make this happen.
Thanks for the help.
Actually pretty simple once I deciphered all the parameters.
The destination image you’re copying to
The source image you’re copying from
The X co-ordinate you want to copy to
The Y co-ordinate you want to copy to
The X co-ordinate you want to copy from
The y co-ordinate you want to copy from
The width in pixels of the source image you want to copy
The height in pixels of the source image you want to copy