vital101 Posted April 20, 2008 Share Posted April 20, 2008 Hey everyone, I'm trying to take a image that is server side, resize it, and then save it another location server side. I've gotten to the point where I save the image, but I don't know how. Any ideas? <?php include('image_scale_functions.php'); $image = open_image('flower.jpg'); if ($image === false) { die ('Unable to open image'); } $width = imagesx($image); $height = imagesy($image); echo "Opened Image"; echo 'Height: ' . $imageY . ' pixels'; echo 'Width: ' . $imageX . ' pixels'; if($width > 110) { $ratio = 110 / $width; $new_width = 110; $new_height = (int)($height * ratio); // Resample $image_resized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); } ?> /vital101 Link to comment https://forums.phpfreaks.com/topic/101949-saving-modified-image-to-server/ Share on other sites More sharing options...
jonsjava Posted April 20, 2008 Share Posted April 20, 2008 <?php include('image_scale_functions.php'); $image_name = "flower.jpg"; $image = open_image($image_name); if ($image === false) { die ('Unable to open image'); } $width = imagesx($image); $height = imagesy($image); echo "Opened Image"; echo 'Height: ' . $imageY . ' pixels'; echo 'Width: ' . $imageX . ' pixels'; if($width > 110) { $ratio = 110 / $width; $new_width = 110; $new_height = (int)($height * ratio); // Resample $image_resized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); $output = "whatever was returned from imagecopyresampled"; $new_image = $image_name."_resized.jpg"; $new_file = fopen($new_image, "+w"); fwrite($new_file, $output); fclose($new_file); } ?> Link to comment https://forums.phpfreaks.com/topic/101949-saving-modified-image-to-server/#findComment-521733 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.