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

  1. $ir = new ImageResizer();
  2. $ir->setFormat(ImageResizer::FORMAT_PNG);
  3. $ir->setSource("./original.jpg");
  4. $ir->resize(0.5);
  5. $ir->setDestination("./avatar.png");
  6. $ir->writeOutput();

Or you can specify what width and height you want and it will calculate the needed ratio keeping the proportions.

  1. $resizer = new ImageResizer();
  2. $resizer->setFormat(ImageResizer::FORMAT_JPEG);
  3. $resizer->setSource("./original.jpg");
  4. $resizer->setWidth(120);
  5. $resizer->setHeight(90);
  6. $resizer->resize();
  7. $resizer->setDestination("./thumbnail.jpg");
  8. $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.

ImageResizer.zip
ImageResizer.tar.gz

One Response to “PHP Image Resize”
  1. [...] на който избирате как да изглежда Вашия аватар и един безплатен php-клас, който прави необходимите редакции. Пробвайте го сами! [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word