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

is this the proper use of mysql_real_escape_string() to prevent sql injections?
i was wondering is this the proper use of mysql_real_escape_string() to prevent sql injections? any

Socket programming
Hello all,

I have a PHP socket script. GPS trackers connect to this socket. IMEI verification

MySQL Primary key gap
Alright, so I have a table with 26 entries in it (id, filename, caption) for my image randomiser (ht

Help with Hyperlink
Hi,

What I am trying to do may be simple, I just can't get it to work. Ok...

I am usin

How to insert random unique values in 2 columns ?
I have table with 2 columns

Create Table code_for_code (
first_code varchar2(10) uni

Database/Table Collation
What is the Database, and table collations used for? i don't understand what there used for since co

How a counter of users ? such as ---> (231 Viewing)
I want to count how many users are actually viewing the page, How is that possible?
Thank you guy

MFC GUI Programming
I am working on a project right now that requires me to create a MFC Windows GUI. Basically it need

MySQL query problem
When I try to run the following piece of code, I get this error:
QuoteWarning: mysql_query(): sup

Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to

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