Image Resizing With Php

General discussions related to php

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 2
Joined: Sun Nov 11, 2012 9:18 am

Image Resizing With Php

Postby designanddev » Sun Nov 11, 2012 9:21 am

Ok, im new to php and trying to develop an app that allows me to upload image then resize them only on the output, i managed to save the image on the server in a folder, now i want to be able to display this images on the site in different sizes depending on what part of the site. like thumbnails and a bigger scale ect...

so far i have this code

$image_properties = getimagesize("uploads/orders.jpg");
$image_width = $image_properties[0];
$image_height = $image_properties[1];
$image_ratio = $image_width / $image_height;

echo"<img src=\"$image_ratio\">";

here i trying to divide the image by half... i no im a long way off i thought this would work due to retrieving the image size properties then dividing it by half, then echoing it out in an image tag, haha....
eventually i would like to master this and be able to change the size by assigning numbers to variable, keeping the size proportions.
help on this topic would be great, i serious need it breaking down, am i far off?

Kind Regards

php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: Image Resizing With Php

Postby seandisanti » Mon Nov 12, 2012 2:24 pm

first, dividing something by half doubles it, which is the opposite of what it sounds like you're trying to do. Second, you can use <img src="..." style="width:Npx;height:Npx;" /> where N represents the desired height and width respectively.

Return to “PHP General”

Who is online

Users browsing this forum: Baidu [Spider] and 4 guests