Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9100049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:46:17+00:00 2026-06-17T00:46:17+00:00

I am extending an image canvas with PHP gd: $newimage = imagecreatetruecolor($imageWidth + 840,

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:46:18+00:00Added an answer on June 17, 2026 at 12:46 am

    Actually pretty simple once I deciphered all the parameters.

    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)
    
    • 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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am extending the ImageBox control from EmguCV. The control's Image property can be
Im extending the UIButton Class to be able to set the font and color
I have a custom control extending Image, and I will put some more data
I create a custom image view by extending ImageView that just draws some text
Is there a way to prevent an absolutely placed image from extending into certain
I am extending an image viewer to support slideshow functionality. I have used a
I'm extending Apple's template for lazy table image loading . I would like the
So color image length will change dynamically. I will use it on the custom
I am extending the WPF textbox in order to place a custom image on
I am extending an inventory management system to retain an item's image order. Originally,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.