Image Resizing with PHP





0
Date Submitted Wed. Jul. 7th, 2010 4:19 PM
Revision 1 of 1
Helper jackoder
Tags Image | PHP | resizing
Comments 0 comments
Hello coders,

I want to share with you another codeblock that you can use to resize an image in your projects.

<?php

# Variables
$file ="image.jpg";
$new_file ="image2.jpg";
$new_width =400;
$new_height =300;
$quality=85;

# list
list($width, $height) = getimagesize($file );

# sizes and sources
$sizes = imagecreatetruecolor($new_width, $new_height);
$source = imagecreatefromjpeg($file);
imagecopyresampled($sizes, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($sizes, $new_file, $quality);

?>
 
This code block provides you to resize your images into new sizes that you assigned. You can take a look here that's applied in [link=http://www.damlakartus.com.tr]denizli kartuş[/link] and i wish you success on your projects directly. Regards.

Jack ODERMAN

Comments

There are currently no comments for this snippet.

Voting

Votes Up


Votes Down