Jump to content

Image Resizing With Php


designanddev

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/270567-image-resizing-with-php/
Share on other sites

Do you want to do this because of bandwidth to the server? If this is not the case, then you can use HTML and CSS for this.

http://dev.w3.org/ht...markup/img.html

 

If you really want to re-size it to save bandwidth, then you need to use one of the image processing libraries in PHP, here's a good list of some of them:

http://www.php.net/m...lspec.image.php

 

I've only really used GD:

http://www.php.net/m.../book.image.php

I know it can do what you are asking for and there should be lots of tutorials for it online.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.