how to change image width and height

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mustafa
Forum Newbie
Posts: 3
Joined: Mon Jun 30, 2003 3:39 am
Location: pakistan

how to change image width and height

Post by mustafa »

is there any function in php with which we can change the width and height of an image.i have seen so many functions which can get the image wifth and height but i could not find the function which can change the image width and height.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I have moved this to PHP - Normal as it is better suited for questions like this than the PHPMac.com forum.

Mac
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

The physical dimensions of an image can only be changed through the use of ImageMagik or the GD libs via PHP.

ImageMagik is a command line tool which you can exec commands to from PHP:

http://freealter.org/doc_distrib/ImageMagick-5.1.1/

Or with the use of GD you can manipulate the image:

http://www.boutell.com/gd/

Both require you to have certain libs/binaries installed on your server.

Regards,
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

If you have a version of GD beyond 2.0 you could adapt my thumbnailing class to do the resizing

http://www.teckis.com/scriptix/thumbnails/teck.html

for simple resizing, just

$variable = new Thumbnail('resource.jpg',200,150,'output_image.jpg',85,'');
$variable->create();

would be all that is required (after including the class ;)).
Post Reply