PHP Image Resize Script

Webmaster Tutorials Add comments

This is a little script that is very handy for webmasters who often use the loading of images. As you already may have noticed somethimes images tend to go bad when resizing. That’s why I’m sharing this script with you all. This is definately not hard to modify and I will do my best to explain everything.

This is a simple script that onyl requires the editing of 1 line:

First of all here is how it works:

Resize an image to 25 x 25
<img src=”imgsize.php?w=25&h=25&img=path/to/image.jpg”>

Resize an image to 50% the size
<img src=”iimgsize.php?percent=50&img=path/to/image.jpg”>

Resize an image to 50 pixels wide and autocompute the height
<img src=”iimgsize.php?w=50&img=path/to/image.jpg”>

Resize an image to 100 pixels tall and autocompute the width
<img src=”iimgsize.php?h=100&img=path/to/image.jpg”>

Resize to 50 pixels width OR 100 pixels tall, whichever resulting image is smaller
<img src=”iimgsize.php?w=50&h=100&constrain=1&img=path/to/image.jpg”>

But first of all upload this code to a php file and name it imgsize.php
imagesize.txt

Greetz

Leave a Reply

You must be logged in to post a comment.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in