/** * Grayscale the provided image * * @param Asido_Image &$image * @return boolean * * @access public * @static */ function greyscale(&$image) { return Asido::grayscale($image); }
function generateThumbnail($originalImgPath, $thumbDir, $prefix, $thumbWidth = 0, $thumbHeight = 0, $type = 'resize', $typeParams = array(), $filters = array()) { $thumbSize = AriImageHelper::getThumbnailDimension($originalImgPath, $thumbWidth, $thumbHeight); if (!$thumbSize['w'] || !$thumbSize['h'] || !@is_readable($originalImgPath)) return null; $width = $thumbSize['w']; $height = $thumbSize['h']; $path_parts = pathinfo($originalImgPath); $thumbName = AriImageHelper::generateThumbnailFileName($prefix, $originalImgPath, $width, $height, $type); $thumbImgPath = $thumbDir . DS . $thumbName; if (@file_exists($thumbImgPath) && @filemtime($thumbImgPath) > @filemtime($originalImgPath)) return $thumbName; if (!AriImageHelper::initAsido()) return ; $thumbImg = Asido::image($originalImgPath, $thumbImgPath); $needResize = true; if ($type == 'crop') { Asido::crop( $thumbImg, intval(AriUtils::getParam($typeParams, 'x', 0), 10), intval(AriUtils::getParam($typeParams, 'y', 0), 10), $width ? $width : $height, $height ? $height : $width ); $needResize = false; } else if ($type == 'cropresize') { Asido::crop( $thumbImg, intval(AriUtils::getParam($typeParams, 'x', 0), 10), intval(AriUtils::getParam($typeParams, 'y', 0), 10), intval(AriUtils::getParam($typeParams, 'width', 0), 10), intval(AriUtils::getParam($typeParams, 'height', 0), 10) ); } if ($filters) { if (AriUtils::parseValueBySample( AriUtils::getParam($filters, 'grayscale', false), false) ) { Asido::grayscale($thumbImg); } $rotateFilter = AriUtils::getParam($filters, 'rotate'); if (is_array($rotateFilter) && AriUtils::parseValueBySample( AriUtils::getParam($rotateFilter, 'enable', false), false) ) { $angle = 0; $rotateType = AriUtils::getParam($rotateFilter, 'type', 'fixed'); if ($rotateType == 'random') { $startAngle = intval(AriUtils::getParam($rotateFilter, 'startAngle', 0), 10); $endAngle = intval(AriUtils::getParam($rotateFilter, 'endAngle', 0), 10); $angle = rand($startAngle, $endAngle); } else { $angle = intval(AriUtils::getParam($rotateFilter, 'angle', 0), 10); } $angle = $angle % 360; if ($angle != 0) { Asido::rotate($thumbImg, $angle); } } } if ($needResize) { if (!$width) Asido::height($thumbImg, $height); else if (!$height) Asido::width($thumbImg, $width); else Asido::resize($thumbImg, $width, $height, ASIDO_RESIZE_STRETCH); } $thumbImg->save(ASIDO_OVERWRITE_ENABLED); return $thumbName; }
/** * Grayscale the provided image * * @param asido_image $image * @return boolean * * @access public * @static */ public static function greyscale(asido_image $image) { return Asido::grayscale($image); }