2

Having exhausted the possibility of solving the image resizing issue I posted in Problems rotating and resizing large images, due to having a shared server on which I can't alter the memory allowance or install additional image handling libraries, I wondered if there would be a way for me to use an external website to resize the image and pass it back to my PHP script?

Eg:

$mylargeimage = "http://www.mywebsite.com/uploads/largephoto.jpg";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.imageresizingsite.com/resizethis.php?src=" . $mylargeimage . "&scale=50");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true)

$output = curl_exec($ch);
curl_close($ch);

I don't know if this would work - nor have I found a website which actually resizes images - but is this approach a possibility and does anyone know of a website which would resize images using this kind of approach?

Community
  • 1
  • 1
Andy Groom
  • 619
  • 1
  • 7
  • 15

1 Answers1

1

Try this if you want to resize the image yourself: (i can't test the code right now, i haven't got a local server currently)

$image = $link_to_image;
$source_image = imagecreatefromfile($image);
$source_imagex = imagesx($source_image);
$source_imagey = imagesy($source_image);
$crop_measure = min($source_imagex, $source_imagey);


$to_crop_array = array('x' =>0 , 'y' => 0, 'width' => $crop_measure, 'height'=> $crop_measure);
$thumb_im = imagecrop($source_image, $to_crop_array);

imagejpeg($thumb_im, NULL, 80); //This may change, see the link below in this answer to see the right way to do that (it change because of extension) 
}

?>

Link that maybe help you

Remember that if you need to resize images from php, you should have the gd driver installed on the server, to see if you have them, make a php_info() call in a empty page

IF YOU WANT TO DO THAT REMOTELY THIS SHOULD HELP YOU

Community
  • 1
  • 1
  • Thanks but unfortunately I run into the same issue which is that I don't have enough free memory on the server to manipulate the image, and I can't increase the memory allowance because it's a shared server. – Andy Groom Dec 30 '15 at 10:52
  • hope this can help! If you prefer to do that on another "site" try searching "image resizer api" on the web – Giuseppe De Paola Dec 30 '15 at 10:57