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
https://forums.phpfreaks.com/topic/216024-resizing-and-cropping-an-image/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.