Hi
I’m re-opening my thread about simpleImage (finnaly changing my mind) and would like to know how to output an image file created by the class.
I’m using :
Okay, this is more complex than I thought…
I added the /site/plugins/mythumbdriver/mythumbdriver.php file and paste the SimpleImage class into, and wrote c::set('thumbs.driver', 'mythumbdriver');
Sorry to bother you, but I have noticed that my images from the panel are not rendered as thumbs and I don’t see saved files into the thumbs folder, I have set this in my file :
<?php
thumb::$drivers['mythumbdriver'] = function($thumb) {
try {
$img = new abeautifulsite\SimpleImage($thumb->root());
$img->quality = $thumb->options['quality'];
if (isset($thumb->options['focus']) && isset($thumb->options['fit']) && isset($thumb->options['ratio']) && isset($thumb->options['focusX']) && isset($thumb->options['focusY'])) {
// calculate crop coordinates and width/height for the original image
$focusCropValues = focus::cropValues($thumb);
// crop original image with thumb ratio and resize it to thumb dimensions
$img->crop($focusCropValues['x1'], $focusCropValues['y1'], $focusCropValues['x2'], $focusCropValues['y2'])->thumbnail($thumb->options['width'], $thumb->options['height']);
}
else if ($thumb->options['crop']) {
@$img->thumbnail($thumb->options['width'], $thumb->options['height']);
}
else {
$dimensions = clone $thumb->source->dimensions();
$dimensions->fitWidthAndHeight($thumb->options['width'], $thumb->options['height'], $thumb->options['upscale']);
@$img->resize($dimensions->width(), $dimensions->height());
}
if ($thumb->options['grayscale']) {
$img->desaturate();
}
if ($thumb->options['width']) {
$dimensions = clone $thumb->source->dimensions();
$dimensions->fitWidthAndHeight($thumb->options['width'], $thumb->options['height'], $thumb->options['upscale']);
@$img->resize($dimensions->width(), $dimensions->height());
}
if ($thumb->options['pixelate']) {
$img->pixelate($thumb->options['pixelate']);
}
if ($thumb->options['blur']) {
$img->blur('gaussian', $thumb->options['blurpx']);
}
if ($thumb->options['autoOrient']) {
$img->auto_orient();
}
@$img->save($thumb->destination->root);
} catch(Exception $e) {
$thumb->error = $e;
}
};
// keep backwards compatibility
thumb::$drivers['focus'] = thumb::$drivers['gd'];
Well, the focus stuff only makes sense in the context of the focus crop plugin, so you should leave this out. As I said, it’s an example of how to extend the driver, and you should use the default thumbs driver as a basis…