Oct
05
2008
PHP Image Resize
Posted by: Валентин Караилиев in open source, php, web, tags: gd, gd2, image, open source, php, ratio, resizeThis is a simple PHP class that allows you easy image resizing.
It works with local and remote files.
You can specify the resize ratio. To make the image smaller it should be < 1 and to make it bigger > 1.
-
$ir = new ImageResizer();
-
$ir->setFormat(ImageResizer::FORMAT_PNG);
-
$ir->setSource("./original.jpg");
-
$ir->resize(0.5);
-
$ir->setDestination("./avatar.png");
-
$ir->writeOutput();
Or you can specify what width and height you want and it will calculate the needed ratio keeping the proportions.
-
$resizer = new ImageResizer();
-
$resizer->setFormat(ImageResizer::FORMAT_JPEG);
-
$resizer->setSource("./original.jpg");
-
$resizer->setWidth(120);
-
$resizer->setHeight(90);
-
$resizer->resize();
-
$resizer->setDestination("./thumbnail.jpg");
-
$resizer->writeOutput();
The code is totally free. You can use it and modify it as you wish.
There are some documentation and examples in the package.

Entries (RSS)
[...] на който избирате как да изглежда Вашия аватар и един безплатен php-клас, който прави необходимите редакции. Пробвайте го сами! [...]