2013-01-10 48 views
0

的我扩大与PHP GD图像帆布:PHP GD imagefill - 区域填充到左源

$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像素。不知道如何做到这一点。

感谢您的帮助。

回答

0

一旦我破译了所有的参数,其实很简单。

imagecopy (resource dest_image, resource source_image, int dest_x, int dest_y, int source_x, int source_y, int source_width, int source_height) 
  • 你复制到

  • 目标图像的源图像你从

  • 复制你想要的X坐标复制到

  • 您要复制的Y坐标为

  • 要从

  • 要从

  • 宽度复制要复制

  • 高度的源图像的像素的y坐标复制的X坐标以您想要复制的源图像的像素为单位