Skip to content
August 23, 2008 / ranacse05

Image Resizing with PHP

I was looking for a script that will resize the image automatically . This script resize the image . Here u have to supply a fixed value of width and i’ll resize the image .

// This is the temporary file created by PHP
$uploadedfile = $_FILES['uploadfile']['tmp_name'];

// Create an Image from it so we can do the resize
$src = imagecreatefromjpeg($uploadedfile);

// Capture the original size of the uploaded image


// this line actually does the image resizing, copying from the                            original
// image into the $tmp image

// now write the resized image to disk. I have assumed that you                            want the
// resized, uploaded image file to reside in the ./images subdirectory.
$filename = "images/". $_FILES['uploadfile']['name'];

imagedestroy($tmp); <code>// NOTE: PHP will clean up the temp file it created                            when the request
// has completed.

Note : I found the script here


One Comment

Leave a Comment
  1. harvey / Sep 22 2009 7:57 am

    hi, im new in php and i tried the code above, im not sure but it displays wierd text…am i missing something?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: