Jump to content

Resizing and cropping an image


paulman888888

Recommended Posts

Hello there,

 

Ill get straight to the point :) I want to copy part of an image with a set height and width with as little aspect ratio losing as possible.

 

I tried just copying the size i wanted onto the destination image but when a large image was being used i lost quite alot of the picture. So then I just copied it all across but that compacted the image and I didnt want to do that (well not to that degree although some were funny because they were people.)

 

So what have i got so far; Below is the important function which is doing the job.

function copy_crop_image($width, $height, $new_width, $new_height, $dest, $source, $dx=55, $dy=19){
	$top_x=0;// The x location on the source image
	$top_y=0;// Same as above but for the y
	// $dx and $dy are the destination x y of where to paste the image
	imagecopyresampled($dest, $source, $dx, $dy, $top_x, $top_y, $new_width, $new_height, $width, $height)===false;

}

 

Please can you help me out with guidance on how to resize the image then crop it in one go if possible to save resources. I know it can be done but I just can't think.

 

Thank-you all

Paul Hutchinson

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.