Jump to content

Recommended Posts

Hi All,

 

I am uploading an image file using move_uploaded_file function. and once the image has been uploaded i want to give user an option to change its height and width so that user could change size of the image and then save it again.

 

Is it possible, can anyone help me out how can i do it.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/135857-solved-resizing-a-saved-image-using-php/
Share on other sites

Heres a basic jpeg resize script.. you should be able to tweak this to suite your needs

 

<?php
// File and new size
$filename = 'test.jpg';
$percent = 0.5;

// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);

// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
imagejpeg($thumb, $filename);
?>

  • 4 weeks later...

Heres a basic jpeg resize script.. you should be able to tweak this to suite your needs

 

<?php
// File and new size
$filename = 'test.jpg';
$percent = 0.5;

// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);

// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
imagejpeg($thumb, $filename);
?>

 

Could someone explain me how can i integrate this script into my app. ? I want resizing image jpg file when output only. Size of image remain original but want to make it small when picture requested.

 

Regards

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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