note 109641 deleted from ref.image by danbrown
| From: | danbrown@php.net | Date: | Fri, 10 Aug 2012 16:16:04 +0000 |
| Subject: | note 109641 deleted from ref.image by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190009@lists.php.net to get a copy of this message | ||
Note Submitter: clemsybarite at laposte dot net
----
Here a powerfull open-source class based on the GD library to work easily with your images: http://phpimageworkshop.com/. Also available on github: http://github.com/Sybio/ImageWorkshop
An example, a simple resize on a physical image file on the server:
<?php
// Initializing a layer based on picture.jpg
$layer = new ImageWorkshop(array(
"imageFromPath" => "/path/to/images/picture.jpg",
));
// Resize the layer (and so the picture in background)
$thumbWidth = 200;
$thumbHeight = 100;
$conserveProportion = true;
$layer->resizeInPixel($thumbWidth, $thumbHeight, $conserveProportion);
// Saving the resulting image
$dirPath = __DIR__."/../../../../../../web/uploads/2012";
$filename = "picture-thumb.png";
$createFolders = true;
$backgroundColor = null; // transparent, only for PNG (otherwise it will be white if set null)
$imageQuality = 95; // useless for GIF, usefull for PNG and JPEG (0 to 100%)
$layer->save($dirPath, $filename, $createFolders, $backgroundColor, $imageQuality);
?>