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
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.

Edited by MMDE
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.