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 6654863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:26:31+00:00 2026-05-26T01:26:31+00:00

Actually I don’t know that there is available any php function to crop and

  • 0

Actually I don’t know that there is available any php function to crop and re-size a image with given parameters(x1,y1,x2,y2,width,height) and image name.

I am looking like below function which create new image with given parameters from existing one.

 newimg(x1,y1,x2,y2,width,height,image);

Currently i have got all above parameters with javascript but now i want to crop image according to above parameters.

  • 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-05-26T01:26:32+00:00Added an answer on May 26, 2026 at 1:26 am

    imagecopyresampled() can do just that:

    imagecopyresampled() copies a rectangular portion of one image to another image, smoothly interpolating pixel values so that, in particular, reducing the size of an image still retains a great deal of clarity.

    In other words, imagecopyresampled() will take an rectangular area from src_image of width src_w and height src_h at position (src_x,src_y) and place it in a rectangular area of dst_image of width dst_w and height dst_h at position (dst_x,dst_y).

    If the source and destination coordinates and width and heights differ, appropriate stretching or shrinking of the image fragment will be performed. The coordinates refer to the upper left corner. This function can be used to copy regions within the same image (if dst_image is the same as src_image) but if the regions overlap the results will be unpredictable.


    In your case (untested):

    function newimg($x1, $y1, $x2, $y2, $width, $height, $image) {
        $newimg = ... // Create new image of $width x $height
        imagecopyresampled(
            $newimg, // Destination
            $image, // Source
            0, // Destination, x
            0, // Destination, y
            $x1, // Source, x
            $y1, // Source, y
            $width, // Destination, width
            $height, // Destination, height
            $x2 - $x1, // Source, width
            $y2 - $y1 // Source, height
        );
    
        return $newimg;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know PHP scripts don't actually compile until they are run. However, say I
Is there any way to reboot the JVM? As in don't actually exit, but
There are similar questions, but none answers what I really need. I actually don't
I don't know if variadic is actually the right word, but I'm talking about
How can I select and don't show duplicates? Actually, it's showing like that: apple
What I want to do (I actually don't know if it's possible) is to
So I found out that C(++) programs actually don't compile to plain binary (I
I hate to give the question this heading but I actually don't know whats
I actually don't even know how to call this :P, but... I have one
Somehow my master and my origin/master branch have diverged. I actually don't want them

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.