Jump to content

Save reduced photo


sseeley

Recommended Posts

Hi I have reduced the size of a photo with the following code

 

<?php
// The file
$filename = 'temp.jpg';
$percent = 0.07;

// Content type
header('Content-type: image/jpeg');

// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;

// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

// Output
imagejpeg($image_p, null, 100);

?> 

 

I now want to save this new image to a new location, can anyone help me?

 

Many thanks in advance.

 

Stuart

Link to comment
https://forums.phpfreaks.com/topic/170734-save-reduced-photo/
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.