Image resize


Posted on 16th Feb 2014 07:03 pm by admin

Hi again fellers

I managed to sort out the issues with the folder,

Final hurdle is this:

Code: function ResizeJPEG($filename, $width, $height){
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;
}

$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename); //JPEG
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
return imagejpeg($image_p, $filename, 100); //JPEG
}
Code: ResizeJPEG($target, 500, 500);
If i upload a file that is larger than 500 x 500 then sure that resizes it down too 500

But if i upload a file that is smaller than 500 x 500 then it upsizes the image too 500

How can i leave images smaller than 500 alone?

No comments posted yet

Your Answer:

Login to answer
173 Like 13 Dislike
Previous forums Next forums
Other forums

PHP Captcha Error help - replace the "die" command
Hi All,

I am after a bit of help with a Captcha spam protection box.

The site gave me

Remove letter from numeric textbox
I have a textbox that will search the employee database by entering in the employee ID and it will r

array_combine() trouble w/csv file
I have a problem with a piece of code I wrote to import some records from a csv file into mysql. I h

Email Form Syantax Issue 2
How to make this look FROM:"OUR TEAM" instead of FROM:abc@mail.com

$headers = "

ereg_replace issue
hi there people

i have this code happening with regards to my wamp server. is this something

Login logout link help
Hi all,

Im new to php and Im having trouble creating a login/logout link for my page that dis

eregi to preg
Im converting my regex for php 5.3 and I am stuck on the following

Code: [Select]if((eregi(&q

Need PHP help... have all the elements... just need help putting them together :
Hey Guys,

I was wondering if someone could help me. I am doing a website for a client which

Dynamic memory problem
Hey,

At the beginning of my code, I have this line:

Shape* gShape = 0;

IS Retail & Manufacturing
Hi

Can IS Retail and Manufacturing activities be done in same instance ie. in same client

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash