Jump to content

Image Saver - resizer


Rochtus

Recommended Posts

Dear,

I use a script that resizes a image to the heigth and width i want,

But i want to save it with those new Sizes..

How is this possible?

 

 

I use this script:

<?php

 

$filename = "../../images/SP_A0002.jpg";

 

 

// Set a maximum height and width

$width = 200;

$height = 200;

 

// Content type

 

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

 

 

// Get new dimensions

list($width_orig, $height_orig) = getimagesize($filename);

 

$ratio_orig = $width_orig/$height_orig;

 

if ($width/$height > $ratio_orig) {

  $width = $height*$ratio_orig;

} else {

  $height = $width/$ratio_orig;

}

 

// Resample

$image_p = imagecreatetruecolor($width, $height);

$image = imagecreatefromjpeg($filename);

imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

 

// Output

imagejpeg($image_p, null, 100);

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/163133-image-saver-resizer/
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.