|
|
|
Image Resizing with PHP
0
Hello coders,
I want to share with you another codeblock that you can use to resize an image in your projects.
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);
?>




There are currently no comments for this snippet.