/** * Fixes image orientation * * @since 1.0 * @access public * @param string * @return */ public function fixOrientation() { $exif = FD::get('Exif'); if (!$exif->isAvailable()) { return false; } // Get the mime type for this image $mime = $this->getMime(); // Only image with jpeg are supported. if ($mime != 'image/jpeg') { return false; } // Load exif data. $exif->load($this->meta->path); $orientation = $exif->getOrientation(); switch ($orientation) { case 1: // Do nothing here as the image is already correct. $this->adapter->rotate($this->image, 0); break; case 2: // Flip image horizontally since it's at top right $this->adapter->flop($this->image); break; case 3: // Rotate image 180 degrees left since it's at bottom right $this->adapter->rotate($this->image, 180); break; case 4: // Flip image vertically because it's at bottom left $this->adapter->flip($this->image); break; case 5: // Flip image vertically $this->adapter->flip($this->image); // Rotate image 90 degrees right. $this->adapter->rotate($this->image, -90); break; case 6: // Rotate image 90 degrees right $this->adapter->rotate($this->image, 90); break; case 7: // Flip image horizontally $this->adapter->flop($this->image); // Rotate 90 degrees right. $this->adapter->rotate($this->image, 90); break; case 8: // Rotate image 90 degrees left $this->adapter->rotate($this->image, -90); break; } }
public function asidoResizeImg($args = array(), $crop = false) { asido::driver('gd'); $source_image = $args["source_image"]; $target_image = $args["target_image"]; $width = $args["width"]; $height = $args["height"]; // process crop images $i1 = asido::image($source_image, $target_image); // fit and add white frame if ($crop) { $x = $args["x"]; $y = $args["y"]; Asido::crop($i1, $x, $y, $width, $height); } else { Asido::frame($i1, $width, $height, Asido::Color(255, 255, 255)); } $i1->Save(ASIDO_OVERWRITE_ENABLED); }
function asidoImg($arr) { asido::driver('gd'); $height = $arr['height']; $width = $arr['width']; $x = $arr['x']; $y = $arr['y']; // process $i1 = asido::image($_SERVER["DOCUMENT_ROOT"] . trim($arr['temp_uploadfile']), $_SERVER["DOCUMENT_ROOT"] . trim($arr['new_uploadfile'])); // fit and add white frame if ($arr['thumb'] === true) { Asido::Crop($i1, $x, $y, $width, $height); } else { Asido::Frame($i1, $width, $height, Asido::Color(255, 255, 255)); } // always convert to jpg Asido::convert($i1, 'image/jpg'); $i1->Save(ASIDO_OVERWRITE_ENABLED); $data = array('photo' => $arr['new_uploadfile']); // echo $user_id; // delete old file return $data['photo'] . "|" . $width . "|" . $height; }
function asidoImg($arr) { include 'asido/class.asido.php'; asido::driver('gd'); $height = $arr['height']; $width = $arr['width']; $x = $arr['x']; $y = $arr['y']; // process $i1 = asido::image($arr['temp_uploadfile'], $arr['new_uploadfile']); // fit and add white frame if ($arr['thumb'] === true) { Asido::Crop($i1, $x, $y, $width, $height); } else { Asido::Frame($i1, $width, $height, Asido::Color(255, 255, 255)); } // always convert to jpg Asido::convert($i1, 'image/jpg'); $i1->Save(ASIDO_OVERWRITE_ENABLED); $data = array('photo' => $arr['new_uploadfile']); // echo $user_id; // delete old file echo $data['photo']; }
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; }
/** * 上传信息图片 * @author 肖飞 * @param array $arrFile 图片文件信息数组$_FILES * @param int $num 图片的标号(用于多图上传) * @param array $FileListPicSize 缩略图压缩的尺寸(像素数组,存放目录小图s,中图m,例如:array('s'=>array(50,50),'m'=>array(100,100));) * @param int $FileSourPicSize 原图压缩的尺寸(像素数组,存放目录b,例如:array(600,600)) * @param int $intInfoID 相关数据记录ID,标示新增还是修改。 * @param int $intFetch 是否来自采集 * @param bool $blTime 新文件名是否使用时间戳 * @param string $FileExt 文件后缀名 * @return string */ public function uploadInfoImage($arrFile, $num = null, $FileListPicSize = 0, $FileSourPicSize = 0, $intInfoID = 0, $intFetch = 0, $blTime = true, $FileExt = '') { if ($arrFile['error'] != 0) { switch ($arrFile['error']) { case 1: $strError = '文件超过了 php.ini 中 upload_max_filesize 选项限制的值'; break; case 2: $strError = '文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值'; break; case 3: $strError = '文件只有部分被上传'; break; case 4: $strError = '没有文件被上传'; break; case 6: $strError = '找不到临时文件夹'; break; case 7: $strError = '文件写入失败'; break; } check::AlertExit('文件上传错误!(' . $strError . ')', -1); } if ($arrFile['name']) { $strFileType = strtolower($arrFile['type']); if (!in_array($strFileType, array('image/jpg', 'image/jpeg', 'image/gif', 'image/pjpeg', 'image/png', 'image/x-png'))) { check::AlertExit('文件类型不符合要求(' . $arrFile['type'] . ')', -1); } } if ($intInfoID == 0) { $intID = $this->getMaxID(); } else { $intID = $intInfoID; } $strDir = ceil($intID / $this->arrGCache['cache_filenum']); if (!is_dir($this->arrGPic['FileSavePath'])) { @mkdir($this->arrGPic['FileSavePath']); @chmod($this->arrGPic['FileSavePath'], 0777); } $strMakeDir = $this->arrGPic['FileSavePath'] . 'b/'; if (!is_dir($strMakeDir)) { @mkdir($strMakeDir); @chmod($strMakeDir, 0777); } $strMakeDir = $strMakeDir . $strDir; if (!is_dir($strMakeDir)) { @mkdir($strMakeDir); @chmod($strMakeDir, 0777); } if ($FileExt == '') { $FileExt = strtolower(strrchr($arrFile['name'], '.')); } //取得上传文件扩展名 if ($blTime) { $strTime = time(); } else { $strTime = ''; } if (!empty($num)) { $strPhoto = $strDir . '/' . $intID . '_' . $strTime . "_{$num}" . $FileExt; //存入数据库的图片访问路径 $strPicName = $strMakeDir . '/' . $intID . '_' . $strTime . "_{$num}" . $FileExt; //新图片路径及名称 } else { $strPhoto = $strDir . '/' . $intID . '_' . $strTime . $FileExt; $strPicName = $strMakeDir . '/' . $intID . '_' . $strTime . $FileExt; } if (!empty($FileListPicSize)) { //所有的图都生成缩略图 $strMakeSmallDir = $this->arrGPic['FileSavePath'] . 's/'; if (!is_dir($strMakeSmallDir)) { @mkdir($strMakeSmallDir); @chmod($strMakeSmallDir, 0777); } $strMakeSmallDir = $strMakeSmallDir . $strDir; if (!is_dir($strMakeSmallDir)) { @mkdir($strMakeSmallDir); @chmod($strMakeSmallDir, 0777); } $strMakeMiddleDir = $this->arrGPic['FileSavePath'] . 'm/'; if (!is_dir($strMakeMiddleDir)) { @mkdir($strMakeMiddleDir); @chmod($strMakeMiddleDir, 0777); } $strMakeMiddleDir = $strMakeMiddleDir . $strDir; if (!is_dir($strMakeMiddleDir)) { @mkdir($strMakeMiddleDir); @chmod($strMakeMiddleDir, 0777); } if (!empty($num)) { $strSmallPicName = $strMakeSmallDir . '/' . $intID . '_' . $strTime . "_{$num}" . $FileExt; $strMiddlePicName = $strMakeMiddleDir . '/' . $intID . '_' . $strTime . "_{$num}" . $FileExt; } else { $strSmallPicName = $strMakeSmallDir . '/' . $intID . '_' . $strTime . $FileExt; $strMiddlePicName = $strMakeMiddleDir . '/' . $intID . '_' . $strTime . $FileExt; } $arrTemp = getimagesize($arrFile['tmp_name']); $arrImageInfo["width"] = $arrTemp[0]; $arrImageInfo["height"] = $arrTemp[1]; if (is_array($FileListPicSize)) { //生成s小缩略图 if (!empty($FileListPicSize['s'])) { Asido::Driver('gd'); $i1 = Asido::Image($arrFile['tmp_name'], $strSmallPicName); if ($FileListPicSize['s'][0] == 0) { //小图宽0 if ($FileListPicSize['s'][1] > 0) { Asido::height($i1, $FileListPicSize['s'][1]); $i1->save(ASIDO_OVERWRITE_ENABLED); } } elseif ($FileListPicSize['s'][1] == 0) { //小图高0 Asido::width($i1, $FileListPicSize['s'][0]); $i1->save(ASIDO_OVERWRITE_ENABLED); } elseif (Asido::resize($i1, $FileListPicSize['s'][0], $FileListPicSize['s'][1], $this->arrGPic['zoomMode'])) { $i1->save(ASIDO_OVERWRITE_ENABLED); } else { check::AlertExit($strSmallPicName . '缩略图生成错误!', -1); } } //生成m中缩略图 if (!empty($FileListPicSize['m'])) { Asido::Driver('gd'); $i1 = Asido::Image($arrFile['tmp_name'], $strMiddlePicName); if ($FileListPicSize['m'][0] == 0) { if ($FileListPicSize['m'][1] > 0) { Asido::height($i1, $FileListPicSize['m'][1]); $i1->save(ASIDO_OVERWRITE_ENABLED); } } elseif ($FileListPicSize['m'][1] == 0) { Asido::width($i1, $FileListPicSize['m'][0]); $i1->save(ASIDO_OVERWRITE_ENABLED); } elseif (Asido::resize($i1, $FileListPicSize['m'][0], $FileListPicSize['m'][1], $this->arrGPic['zoomMode'])) { $i1->save(ASIDO_OVERWRITE_ENABLED); } else { check::AlertExit($strMiddlePicName . '缩略图生成错误!', -1); } } } else { if (!empty($FileListPicSize)) { check::AlertExit('缩略图的定义格式已经升级,请检查var.inc.php中$arrGPic[FileListPicSize]的定义!', -1); } } } if (!empty($FileSourPicSize)) { //原图容量>最大容量设定,就自动压缩原图 if ($intFetch) { copy($arrFile['tmp_name'], $strPicName); } else { move_uploaded_file($arrFile['tmp_name'], $strPicName); } if (is_array($FileSourPicSize)) { Asido::Driver('gd'); $i1 = Asido::Image($strPicName, $strPicName); if ($FileSourPicSize[0] == 0) { //设定宽=0,则不定宽,定高压缩 if ($FileSourPicSize[1] > 0 && $FileSourPicSize[1] < $arrImageInfo['height']) { Asido::height($i1, $FileSourPicSize[1]); if ($this->arrGPic['waterMark']) { Asido::watermark($i1, __WEB_ROOT . "/data/" . $this->arrGPic['waterImage'], $this->arrGPic['waterPos'], ASIDO_WATERMARK_SCALABLE_ENABLED, 0.5); } $i1->save(ASIDO_OVERWRITE_ENABLED); } return $strPhoto; } elseif ($FileSourPicSize[1] == 0) { //设定高=0,则不定高,定宽压缩 if ($FileSourPicSize[0] > 0 && $FileSourPicSize[0] < $arrImageInfo['width']) { Asido::width($i1, $FileSourPicSize[0]); if ($this->arrGPic['waterMark']) { Asido::watermark($i1, __WEB_ROOT . "/data/" . $this->arrGPic['waterImage'], $this->arrGPic['waterPos'], ASIDO_WATERMARK_SCALABLE_ENABLED, 0.5); } $i1->save(ASIDO_OVERWRITE_ENABLED); } return $strPhoto; } elseif (Asido::resize($i1, $FileSourPicSize[0], $FileSourPicSize[1], $this->arrGPic['zoomMode'])) { //定宽,定高压缩 if ($this->arrGPic['waterMark']) { Asido::watermark($i1, __WEB_ROOT . "/data/" . $this->arrGPic['waterImage'], $this->arrGPic['waterPos'], ASIDO_WATERMARK_SCALABLE_ENABLED, 0.5); } $i1->save(ASIDO_OVERWRITE_ENABLED); return $strPhoto; } else { check::AlertExit($strPicName . '文件上传错误!', -1); } } else { if (!empty($FileSourPicSize)) { check::AlertExit('原图的定义格式已经升级,请检查var.inc.php中$arrGPic[FileSourPicSize]的定义!', -1); } } } else { //原图容量<=最大容量设定,就不压缩原图 if ($intFetch) { if (copy($arrFile['tmp_name'], $strPicName)) { return $strPhoto; } else { echo $strPicName . '文件上传错误!'; exit; } } else { if (move_uploaded_file($arrFile['tmp_name'], $strPicName)) { return $strPhoto; } else { check::AlertExit($strPicName . '文件上传错误!', -1); } } } }
* Crop Example #01 * * This example shows ... * * @filesource * @package Asido.Examples * @subpackage Asido.Examples.Crop */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.png', 'result_01.jpg'); /** * Crop a portion of the image from the upper left corner */ Asido::Crop($i1, 0, 0, 300, 300); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
Asido::resize($img, $previewWidth, $previewHeight, ASIDO_RESIZE_STRETCH); } else { if (strstr($convertImage, 'rotate')) { $rotateAttrs = explode(':', $convertImage); if (!$rotateAttrs[1]) { $rotateAttrs[1] = 90; } Asido::Rotate($img, $rotateAttrs[1]); } else { if (!$previewWidth) { Asido::height($img, $previewHeight); } else { if (!$previewHeight) { Asido::width($img, $previewWidth); } else { Asido::resize($img, $previewWidth, $previewHeight, ASIDO_RESIZE_STRETCH); } } } } } $img->save(ASIDO_OVERWRITE_ENABLED); } $imagesCode .= JURI::root() . "images/artsexylightbox_tmp/{$generatedThumbName}' "; } } else { $imagesCode .= JURI::root() . "{$path}/{$entry}' "; } } if ($previewHeight) { $imagesCode .= " height='{$previewHeight}' ";
/** * Grayscale the provided image * * @param asido_image $image * @return boolean * * @access public * @static */ public static function greyscale(asido_image $image) { return Asido::grayscale($image); }
* * This example shows the "tiling-watermark" feature, which tiles the watermark * image all over across the watermarked image. * * @filesource * @package Asido.Examples * @subpackage Asido.Examples.Watermark */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.jpg', 'result_02.jpg'); /** * Put a "tile" watermark image */ Asido::watermark($i1, 'watermark_02.png', ASIDO_WATERMARK_TILE); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
function getSexyLightboxCode($id, $finalParams, $content = '') { $path = $finalParams['path']; $theme = $finalParams['theme']; $previewWidth = $finalParams['previewWidth']; $previewHeight = $finalParams['previewHeight']; $noConflict = $finalParams['noConflict']; $flickr = $finalParams['flickr']; $thumbnailPath = $finalParams['thumbnailPath']; $singleImage = $finalParams['singleImage']; $singleText = $finalParams['singleText']; $thumbnailPreviewCount = $finalParams['thumbnailPreviewCount']; $popup = $finalParams['popup']; $autoGenerateThumbs = $finalParams['autoGenerateThumbs']; $flickrNumberOfImages = $finalParams['flickrNumberOfImages']; $numberOfImages = $finalParams['numberOfImages']; $sort = $finalParams['sort']; if (!$flickrNumberOfImages) { $flickrNumberOfImages = 20; } $imagesCode = ''; $jsCode = '<script type="text/javascript" charset="utf-8">'; if ($noConflict) { $document =& JFactory::getDocument(); $document->addCustomTag('<script type="text/javascript" charset="utf-8">jQuery.noConflict();</script>'); } $jsonHandler = new ART_Services_JSON(SERVICES_JSON_LOOSE_TYPE); $dFP = !empty($finalParams) ? $jsonHandler->encode($finalParams) : ''; if ($path) { if ($thumbnailPath) { $thumbs = array(); $thumb_directory_stream = @opendir(JPATH_SITE . DS . $thumbnailPath . DS); if ($thumb_directory_stream) { while ($entry = readdir($thumb_directory_stream)) { if ($entry != '.' && $entry != '..' && plgContentartsexylightbox::isImage($thumbnailPath . $entry)) { $thumbs[$entry] = $entry; } } } } $file_handle = @fopen(JPATH_SITE . DS . $path . DS . "artsexylightbox.txt", "rb"); $descriptionArray = array(); if ($file_handle) { while (!feof($file_handle)) { $line_of_text = fgets($file_handle); $parts = explode('=', $line_of_text); $descriptionArray[$parts[0]] = $parts[1]; } fclose($file_handle); } $id = uniqid('artgallery_', false); $jsCode .= 'if (!window.sexylightboxEnabled) {jQuery(document).ready(function(){SexyLightbox.initialize(' . $dFP . ')});} if (!window.sexylightboxEnabled) {window.sexylightboxEnabled = true;}</script>'; $directory_stream = @opendir(JPATH_SITE . DS . $path . DS) or die("Could not open a directory stream for <i>" . JPATH_SITE . DS . $path . DS . "</i>"); $filelist = array(); while ($entry = readdir($directory_stream)) { if ($entry != '.' && $entry != '..' && plgContentartsexylightbox::isImage($path . $entry)) { $filelist[] = $entry; } } if ($sort == 'desc') { usort($filelist, 'artSLFileDescSort'); } else { usort($filelist, 'artSLFileAscSort'); } if ($thumbnailPreviewCount && $thumbnailPreviewCount > count($filelist)) { $thumbnailPreviewCount = count($filelist); } if ($singleImage) { $imagesCode .= "<a onclick='jQuery(\"a[rel*=" . $id . "]\").eq(0).click();return false;'><img class='artsexylightbox_singleimage' src='" . JURI::root() . $singleImage . "'"; if ($previewHeight) { $imagesCode .= " height='{$previewHeight}'"; } if ($previewWidth) { $imagesCode .= " width='{$previewWidth}' "; } $imagesCode .= " /></a>"; } else { if ($singleText) { $imagesCode .= "<a onclick='jQuery(\"a[rel*=" . $id . "]\").eq(0).click();return false;'><span class='artsexylightbox_singletext'>" . $singleText . "</span></a>"; } else { if ($thumbnailPreviewCount && $thumbnailPreviewCount > 0) { $thumbsCount = 0; while ((list($key, $entry) = each($filelist)) && $thumbsCount < $thumbnailPreviewCount) { if ($entry != '.' && $entry != '..' && plgContentartsexylightbox::isImage($path . $entry)) { $imagePath = JPATH_SITE . DS . $path . DS . $entry; if ($thumbs && isset($thumbs[$entry])) { $imagesCode .= "<a onclick='jQuery(\"a[rel*=" . $id . "]\").eq(0).click();return false;'><img class='artsexylightbox_singleimage' src='" . JURI::root() . $thumbnailPath . '/' . $entry . "'"; } else { $imagesCode .= "<a onclick='jQuery(\"a[rel*=" . $id . "]\").eq(0).click();return false;'><img class='artsexylightbox_singleimage' src='" . JURI::root() . $path . '/' . $entry . "'"; } if ($previewHeight) { $imagesCode .= " height='{$previewHeight}'"; } if ($previewWidth) { $imagesCode .= " width='{$previewWidth}' "; } $imagesCode .= " /></a>"; $thumbsCount++; } } } } } reset($filelist); $imagesCount = 0; while ((list($key, $entry) = each($filelist)) && ($numberOfImages > 0 ? $imagesCount < $numberOfImages : 1 == 1)) { if ($entry != '.' && $entry != '..' && plgContentartsexylightbox::isImage($path . $entry)) { $title = ''; if (isset($descriptionArray[$entry])) { $title = $descriptionArray[$entry]; } $imagesCode .= "<a href='" . JURI::root() . "{$path}/{$entry}' rel='sexylightbox[" . $id . "]' class='artsexylightboxpreview' "; if ($title) { $imagesCode .= " title='" . $title . "'"; } $imagesCode .= "><img class='artsexylightbox' "; if ($singleImage || $thumbnailPreviewCount || $singleText) { $imagesCode .= " style='display:none;'"; } $imagesCode .= " src='"; $imagePath = JPATH_SITE . DS . $path . DS . $entry; if ($thumbs && isset($thumbs[$entry])) { $imagesCode .= JURI::root() . "{$thumbnailPath}/{$entry}' "; } else { if (@is_readable($imagePath) && ($previewWidth > 0 || $previewHeight > 0) && isset($autoGenerateThumbs) && $autoGenerateThumbs != 'false') { if (!plgContentartsexylightbox::isExtensionsLoaded()) { plgContentartsexylightbox::loadExtensions(); } if (!plgContentartsexylightbox::isExtensionsLoaded()) { $imagesCode .= JURI::root() . "{$path}/{$entry}' "; } else { $imagePathInfo = pathinfo($imagePath); $generatedThumbName = sprintf('%s_%s_%s.%s', md5('artsexythumb_' . $imagePath), $previewWidth, $previewHeight, $imagePathInfo['extension']); if (!file_exists(JPATH_SITE . DS . 'images' . DS . 'artsexylightbox_tmp')) { mkdir(JPATH_SITE . DS . 'images' . DS . 'artsexylightbox_tmp'); } $thumbPath = JPATH_SITE . DS . 'images' . DS . 'artsexylightbox_tmp' . DS . $generatedThumbName; if (!@file_exists($thumbPath)) { $img = asido::image($imagePath, $thumbPath); if (!$previewWidth) { Asido::height($img, $previewHeight); } else { if (!$previewHeight) { Asido::width($img, $previewWidth); } else { Asido::resize($img, $previewWidth, $previewHeight, ASIDO_RESIZE_STRETCH); } } $img->save(ASIDO_OVERWRITE_ENABLED); } $imagesCode .= JURI::root() . "images/artsexylightbox_tmp/{$generatedThumbName}' "; } } else { $imagesCode .= JURI::root() . "{$path}/{$entry}' "; } } if ($previewHeight) { $imagesCode .= " height='{$previewHeight}' "; } if ($previewWidth) { $imagesCode .= "width='{$previewWidth}' "; } $imagesCode .= "/></a>"; } $imagesCount++; } if (isset($popup) && $popup == 'false') { return $imagesCode; } return $imagesCode . $jsCode; } else { if ($flickr) { $flickrApiKey = $finalParams['flickrApiKey']; $flickrSet = $finalParams['flickrSet']; $flickrThumbSize = $finalParams['flickrThumbSize']; if (!isset($flickrThumbSize)) { $flickrThumbSize = "s"; } $flickrImageSize = $finalParams['flickrImageSize']; if (!isset($flickrImageSize)) { $flickrImageSize = "m"; } $id = uniqid('artgallery_', false); if (isset($flickrApiKey) && isset($flickrSet)) { $imagesCode .= "<div id='{$id}' class='artflickrgallery'></div>"; $jsCode .= 'jQuery(document).ready(function(){jQuery("#' . $id . '").flickr({find: "' . $id . '", thumb_size:"' . $flickrThumbSize . '",size:"' . $flickrImageSize . '",per_page:' . $flickrNumberOfImages . ',api_key:"' . $flickrApiKey . '",photoset_id:"' . $flickrSet . '", user_id: "' . $flickr . '", type: "photoset", callback: function(el) {SexyLightbox.initialize(' . $dFP . ')} })})</script>'; } else { $flickrLargeImages = $finalParams['flickrLargeImages']; $flickrSmallThumbs = $finalParams['flickrSmallThumbs']; $jsCode .= 'if (!window.sexylightboxEnabled) {jQuery(document).ready(function(){SexyLightbox.initialize(' . $dFP . ')});} if (!window.sexylightboxEnabled) {window.sexylightboxEnabled = true;}</script>'; if (strstr($flickr, ',')) { $ids = explode(',', $flickr); } else { $id = $flickr; } if ($id) { $url = 'http://api.flickr.com/services/feeds/photos_public.gne?format=php_serial&id=' . $id; } else { $url = 'http://api.flickr.com/services/feeds/photos_public.gne?format=php_serial&ids=' . $ids; } if ($fp = fopen($url, 'r')) { $content = ''; while ($line = fread($fp, 1024)) { $content .= $line; } $rsp_obj = unserialize($content); $i = 1; foreach ($rsp_obj['items'] as $image) { if ($i > $flickrNumberOfImages) { break; } $title = $image['title']; $largeImagePath = $image['m_url']; $smallThumbPath = $image['m_url']; if ($flickrLargeImages) { $largeImagePath = $image['l_url']; } if ($flickrSmallThumbs) { $smallThumbPath = $image['t_url']; } $imagesCode .= "<a href='" . $largeImagePath . "' rel='sexylightbox[" . $id . "]' class='artsexylightboxpreview' "; if ($title) { $imagesCode .= "title='" . $title . "'"; } $imagesCode .= "><img class='artsexylightbox' src='" . $smallThumbPath . "'"; if ($previewHeight) { $imagesCode .= " height='{$previewHeight}' "; } if ($previewWidth) { $imagesCode .= "width='{$previewWidth}' "; } $imagesCode .= "/></a>"; $i++; } } } if (isset($popup) && $popup == 'false') { return $imagesCode; } return $imagesCode . $jsCode; } else { if (isset($content) && !empty($content)) { $theme = $finalParams['theme']; $width = $finalParams['width']; $height = $finalParams['height']; $background = $finalParams['background']; $modal = $finalParams['modal']; $text = $finalParams['text']; $title = $finalParams['title']; $hideContent = $finalParams['hideContent']; $id = uniqid('artinline_', false); $url = "#TB_inline?inlineId={$id}"; if (!$height) { $height = "100"; } if (!$width) { $width = "300"; } if (isset($height) && !empty($height)) { $url .= "&height={$height}"; } if (isset($width) && !empty($width)) { $url .= "&width={$width}"; } if (isset($modal) && !empty($modal)) { $url .= "&modal={$modal}"; } $inlineCode = "<span id='{$id}'>{$content}</span><a href='{$url}' rel='sexylightbox' title='{$title}'>{$text}</a>"; $jsCode .= 'jQuery(document).ready(function(){SexyLightbox.initialize(' . $dFP . ');'; if ($hideContent) { $jsCode .= 'document.getElementById("' . $id . '").style.display = "none";'; } $jsCode .= '}); if (!window.sexylightboxEnabled) {window.sexylightboxEnabled = true;}</script>'; return $jsCode . $inlineCode; } else { $jsCode .= 'if (!window.sexylightboxEnabled) {jQuery(document).ready(function(){SexyLightbox.initialize(' . $dFP . ')});} if (!window.sexylightboxEnabled) {window.sexylightboxEnabled = true;}</script>'; return $jsCode; } } } }
* @filesource * @package Asido.Examples * @subpackage Asido.Examples.Watermark */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.jpg', 'result_05.jpg'); /** * Put a JPEG watermark image */ Asido::watermark($i1, 'watermark_05.jpg', ASIDO_WATERMARK_TOP_LEFT); /** * Put a GIF watermark image */ Asido::watermark($i1, 'watermark_05.gif', ASIDO_WATERMARK_BOTTOM_RIGHT); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
* @filesource * @package Asido.Examples * @subpackage Asido.Examples.Watermark */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.jpg', 'result_03.jpg'); /** * Put the watermark with the scaling feature enabled */ Asido::watermark($i1, 'watermark_03.png', ASIDO_WATERMARK_BOTTOM_RIGHT, ASIDO_WATERMARK_SCALABLE_ENABLED); /** * Put the watermark with the scaling feature disabled */ Asido::watermark($i1, 'watermark_03.png', ASIDO_WATERMARK_CENTER, ASIDO_WATERMARK_SCALABLE_DISABLED); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
* @filesource * @package Asido.Examples * @subpackage Asido.Examples.Watermark */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.jpg', 'result_04.jpg'); /** * Put the watermark with the scaling factor 0.66 */ Asido::watermark($i1, 'watermark_04.png', ASIDO_WATERMARK_TOP_LEFT, ASIDO_WATERMARK_SCALABLE_ENABLED, 0.66); /** * Put the watermark with the scaling factor 0.75 */ Asido::watermark($i1, 'watermark_04.png', ASIDO_WATERMARK_BOTTOM_RIGHT, ASIDO_WATERMARK_SCALABLE_ENABLED, 0.75); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
* This example shows how to flop an image. Flop means to do a horizontal mirror. * We are using the `gd_hack` driver since the flipping and flopping is not * supported by the regular `gd` driver. * * @filesource * @package Asido.Examples * @subpackage Asido.Examples.Rotate */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd_hack'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.png', 'result_04.png'); /** * Flop it ;) */ Asido::Flop($i1); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
/** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.jpg', 'result_01.jpg'); /** * Put a watermark image on every possible gravity location */ $watermark = 'watermark_01.png'; Asido::watermark($i1, $watermark, ASIDO_WATERMARK_TOP_LEFT); Asido::watermark($i1, $watermark, ASIDO_WATERMARK_TOP_CENTER); Asido::watermark($i1, $watermark, ASIDO_WATERMARK_TOP_RIGHT); Asido::watermark($i1, $watermark, ASIDO_WATERMARK_MIDDLE_LEFT); Asido::watermark($i1, $watermark, ASIDO_WATERMARK_MIDDLE_CENTER); Asido::watermark($i1, $watermark, ASIDO_WATERMARK_MIDDLE_RIGHT); Asido::watermark($i1, $watermark, ASIDO_WATERMARK_BOTTOM_LEFT); Asido::watermark($i1, $watermark, ASIDO_WATERMARK_BOTTOM_CENTER); Asido::watermark($i1, $watermark, ASIDO_WATERMARK_BOTTOM_RIGHT); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
* * This example shows how to convert an image explicitly declaring the type of * the image disregarding the extension of the "result" image. * * @filesource * @package Asido.Examples * @subpackage Asido.Examples.Convert */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.png', 'result_02.jpg'); /** * Save the result as GIF nevertheless we set the result name to be a JPEG one */ Asido::convert($i1, 'image/gif'); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
* * This example shows how to do a custom rotate by 30 degrees, and we are * filling the blank areas left by the rotate with a nice green color. * * @filesource * @package Asido.Examples * @subpackage Asido.Examples.Rotate */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.png', 'result_02.png'); /** * Rotates the image by 30 degrees */ Asido::Rotate($i1, 30, Asido::Color(39, 107, 20)); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
* This example shows how to flip an image. Flip means to do a vertical mirror. * We are using the `gd_hack` driver since the flipping and flopping is not * supported by the regular `gd` driver. * * @filesource * @package Asido.Examples * @subpackage Asido.Examples.Rotate */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd_hack'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.png', 'result_03.png'); /** * Flip it ;) */ Asido::Flip($i1); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
public function uploadImgFile($uploaddir, $file) { $UploadRes = array(); $UploadRes['error'] = false; if ($file['type'] != 'image/jpeg' && $file['type'] != 'image/gif' && $file['type'] != 'image/png') { $UploadRes['error'] = true; $UploadRes['error_message'] = "Принимаются только форматы GIF, JPEG, PNG. "; return $UploadRes; } $sName = $this->makeNormalName($file['name']); $this->getUploadFileName($uploaddir, $sName); // get a free file name, to not replace other image $sName = $this->_sTmp; $uploadfile = $uploaddir . $sName; if (move_uploaded_file($file['tmp_name'], $uploadfile)) { $asido = new Asido(); $asido->Driver('gd'); $im = $asido->Image($uploadfile, $uploadfile); $asido->Fit($im, 90, 90); $im->Save(ASIDO_OVERWRITE_ENABLED); $UploadRes['file_name'] = $sName; return $UploadRes; } else { $UploadRes['error'] = true; $UploadRes['error_message'] = "Проблема при загрузке файла на сервер. Обратитесь к администратору."; return $UploadRes; } }
function indexAction() { $request = new RivetyCore_Request($this->getRequest()); $basepath = Zend_Registry::get('basepath'); $this->view->timezones = RivetyCore_Common::getTimeZonesArray(); if ($this->getRequest()->isPost()) { $errors = array(); /* * TODO: Check that smarty dirs are writeable, etc. dir is writable, etc. dir is NOT writeable after install, libraries exist, * log level is set to something */ if (!file_exists($basepath . "/.htaccess")) { $errors[] = $this->_T("Missing .htaccess file in %s. Be sure to copy %s/template.htaccess and remove the word template from the filename.", array($basepath, $basepath)); } $zf_version_class = $request->zf_path . "/Zend/Version.php"; $smarty_class_file = $request->smarty_path . "/Smarty.class.php"; $asido_class_file = $request->asido_path . "/class.asido.php"; $etc_dir = $basepath . "/etc"; $config_filename = $etc_dir . "/config.ini"; $tmp_path = $request->tmp_path; $smarty_compile_dir = $tmp_path . "/view_compiles"; $smarty_cache_dir = $tmp_path . "/cache"; $image_cache_dir = $tmp_path . "/image_cache"; $upload_path = $basepath . "/uploads"; $log_path = $request->log_path; $module_cfg = parse_ini_file($basepath . "/core/default/module.ini", true); if (!file_exists($zf_version_class)) { $errors[] = $this->_T("Can't find Zend Framework in %s", $request->zf_path); } else { require_once($zf_version_class); if (Zend_Version::compareVersion($module_cfg['lib_versions']['zf']) > 0) { $errors[] = $this->_T("Rivety requires Zend Framework %s or higher. The supplied version is %s.", array($module_cfg['lib_versions']['zf'], Zend_Version::VERSION)); } } if (!file_exists($smarty_class_file)) { $errors[] = $this->_T("Can't find Smarty in %s", $request->RivetyCore_smarty_path); } else { $smarty_class_lines = explode("\n",file_get_contents($smarty_class_file)); $strVersion = "* @version"; foreach ($smarty_class_lines as $line) { if (strpos($line,$strVersion) !== false) { $found_smarty_version = trim(substr($line,strpos($line,$strVersion) + strlen($strVersion))); break; } } if (version_compare($module_cfg['lib_versions']['smarty'],$found_smarty_version) > 0) { $errors[] = $this->_T("Rivety requires Smarty Template Engine %s or higher. The supplied version is %s.", array($module_cfg['lib_versions']['smarty'], $found_smarty_version)); } } if (!file_exists($asido_class_file)) { $errors[] = $this->_T("Can't find Asido in %s.", $request->RivetyCore_asido_path); } else { require_once($asido_class_file); $asido = new Asido(); if (version_compare($module_cfg['lib_versions']['asido'], $asido->version()) > 0) { $errors[] = $this->_T("Rivety requires Asido %s or higher. The supplied version is %s.", array($module_cfg['lib_versions']['asido'], $asido->version())); } } $dir_array = array($etc_dir, $tmp_path, $upload_path, $log_path ); foreach ($dir_array as $dir) { if (!is_writable($dir)) { $errors[] = $this->_T("Web server can't write to %s.", $dir); } } if ($request->admin_username == null) { $errors[] = $this->_T("Admin username cannot be blank."); } if ($request->admin_email == null) { $errors[] = $this->_T("Admin email cannot be blank."); } $cfg_array = array( "database" => array( "adapter" => "PDO_MYSQL", "params" => array( "host" => $request->db_host, "dbname" => $request->db_name, "username" => $request->db_user, "password" => $request->db_pass, "port" => $request->db_port, ) ) ); if (!is_null($request->db_sock)) { $cfg_array['database']['params']['unix_socket'] = $request->db_sock; // this is often something like /var/run/mysqld/mysqld.sock } $dbconfig = new Zend_Config($cfg_array); $db = Zend_Db::factory($dbconfig->database); try { if (count($errors) == 0) { $tables = $db->listTables(); if (count($tables) > 0) { $errors[] = $this->_T("The specified database is not empty."); } // get the table creation script $ddl_file = $basepath . "/core/default/sql/" . $dbconfig->database->adapter . "/install.sql"; if (file_exists($ddl_file)) { $queries = explode(";",file_get_contents($ddl_file)); $db->beginTransaction(); try { foreach ($queries as $query) { if (trim($query) != "") { $query = str_replace("@@@@ADMIN_USERNAME@@@@", $request->admin_username, $query); $query = str_replace("@@@@ADMIN_EMAIL@@@@", $request->admin_email, $query); $query = str_replace("@@@@CREATED_ON@@@@@", date("Y-m-d H:i:s"), $query); $db->query($query); } } $db->commit(); } catch (Exception $e) { $db->rollBack(); $errors[] = $e->getMessage(); } } else { $errors[] = $this->_T("Database creation script not found."); } } } catch (Exception $e) { $errors[] = $e->getMessage(); } if (count($errors) == 0) { // everything worked out okay, attempt to write the config file $config = array( "db.rivety.adapter" => "PDO_MYSQL", // This should really be configurable, but it isn't yet. "db.rivety.config.host" => $request->db_host, "db.rivety.config.dbname" => $request->db_name, "db.rivety.config.username" => $request->db_user, "db.rivety.config.password" => $request->db_pass, "db.rivety.config.port" => $request->db_port, "db.rivety.config.default" => "true", ); if (!is_null($request->db_sock)) { $config['db.rivety.config.unix_socket'] = $request->db_sock; } $config_file .= RivetyCore_ConfigFile::makeSection("databases", "Database Settings", "This is the default database.", $config); $RivetyCore_config = array( "timezone" => $request->RivetyCore_timezone, "launched" => "1", "prelaunch_url" => "http://google.com", "allowed_ips" => "127.0.0.1", "zf_path" => $request->zf_path, "smarty_path" => $request->smarty_path, "asido_path" => $request->asido_path, "image_cache_dir" => $image_cache_dir, "log_filename" => $log_path."/RivetyCore_log", "log_level" => "6", "addtl_includes" => "", ); $config_file .= RivetyCore_ConfigFile::makeSection("application", "Application Settings", "These are the application specific settings.", $RivetyCore_config); // create directories if needed if (!file_exists($smarty_compile_dir)) { mkdir($smarty_compile_dir, 0777, true); } if (!file_exists($smarty_cache_dir)) { mkdir($smarty_cache_dir, 0777, true); } if (!file_exists($image_cache_dir)) { mkdir($image_cache_dir, 0777, true); } $smarty_config = array( "config.compile_dir" => $smarty_compile_dir, "config.cache_dir" => $smarty_cache_dir, ); $config_file .= RivetyCore_ConfigFile::makeSection("smarty", "Smarty Settings", "These are the settings for the Smarty template engine.", $smarty_config); if (file_put_contents($config_filename, $config_file) === false) { $this->view->config_file = $config_file; $this->view->config_filename = $config_filename; $this->view->success = "Database installed, but could not write config file. Please create the file \"" . $config_filename . "\" and paste this following into it:"; } else { $this->_redirect("/default/install/secondstage/username/" . $request->admin_username); } } else { $this->view->errors = $errors; $this->view->db_host = $request->db_host; $this->view->db_name = $request->db_name; $this->view->db_user = $request->db_user; $this->view->db_pass = $request->db_pass; $this->view->db_port = $request->db_port; $this->view->db_sock = $request->db_sock; $this->view->admin_username = $request->admin_username; $this->view->admin_email = $request->admin_email; $this->view->timezone = $request->timezone; $this->view->zf_path = $request->zf_path; $this->view->smarty_path = $request->smarty_path; $this->view->asido_path = $request->asido_path; $this->view->tmp_path = $request->tmp_path; $this->view->log_path = $request->log_path; } } else { $this->view->db_host = "localhost"; $this->view->db_name = "rivety"; $this->view->db_user = "******"; $this->view->db_pass = ""; $this->view->db_port = "3306"; $this->view->db_sock = ""; $this->view->admin_username = "******"; $this->view->timezone = "America/Los_Angeles"; $this->view->zf_path = $basepath . "/lib/ZendFramework/library"; $this->view->smarty_path = $basepath . "/lib/Smarty/libs"; $this->view->asido_path = $basepath . "/lib/Asido"; $this->view->tmp_path = $basepath . "/tmp"; $this->view->log_path = $basepath . "/logs"; } $this->view->admin_theme_url = "/core/default/views/admin"; $this->view->admin_theme_global_path = $basepath . "/core/default/views/admin/tpl_common"; }
function asidoImg($arr) { include dirname(__FILE__) . '/../Util/asido/class.asido.php'; asido::driver('gd'); $height = $arr['height']; $width = $arr['width']; $x = $arr['x']; $y = $arr['y']; // process $i1 = asido::image($arr['temp_uploadfile'], $arr['new_uploadfile']); // fit and add white frame if ($arr['thumb'] === true) { Asido::Crop($i1, $x, $y, $width, $height); } else { // rotate the image if it is portrait // switch($arr['orientation']) // { // case 1: // nothing // break; // case 2: // horizontal flip // break; // case 3: // 180 rotate left // Asido::Rotate($i1,180); // break; // case 4: // vertical flip // break; // case 5: // vertical flip + 90 rotate right // break; // case 6: // 90 rotate right // Asido::Rotate($i1,90); // break; // case 7: // horizontal flip + 90 rotate right // break; // case 8: // 90 rotate left // Asido::Rotate($i1,-90); // break; // } Asido::Frame($i1, $width, $height, Asido::Color($arr['canvasbg']['r'], $arr['canvasbg']['b'], $arr['canvasbg']['g'])); } // always convert to jpg Asido::convert($i1, 'image/jpg'); $i1->Save(ASIDO_OVERWRITE_ENABLED); $data = array('photo' => $arr['web_file']); // echo $user_id; // delete old file echo $data['photo']; }
/** * Grayscale the provided image * * @param Asido_Image &$image * @return boolean * * @access public * @static */ function greyscale(&$image) { return Asido::grayscale($image); }
* @filesource * @package Asido.Examples * @subpackage Asido.Examples.Crop */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.png', 'result_02.jpg'); /** * Copy the image with over the resulting image */ Asido::copy($i1, 'copy_01.png', 15, 15); /** * Copy an image using negative coordinates */ Asido::copy($i1, 'copy_02.jpg', -35, -35); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
* Resize Example #01 * * This example shows how the proportional resize only by one dimension (height) works * * @filesource * @package Asido.Examples * @subpackage Asido.Examples.Resize */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.png', 'result_01.png'); /** * Resize the image proportionally only by setting only the height, and the width will be corrected accordingly */ Asido::height($i1, 400); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
* * This example shows how to grayscale an image. We are using the `gd_hack` * driver since the "greyscalling" is not supported by the regular `gd` driver. * * @filesource * @package Asido.Examples * @subpackage Asido.Examples.Convert */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd_hack'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.png', 'result_03.png'); /** * Do grayscale it ;) */ Asido::GreyScale($i1); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
* Rotate Example #01 * * This example shows how to rotate an image by 90 degrees. * * @filesource * @package Asido.Examples * @subpackage Asido.Examples.Rotate */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.png', 'result_01.png'); /** * Rotates the image by 90 degrees */ Asido::Rotate($i1, 90); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ Asido::Driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = Asido::Image('example.png', 'result_04_1.png'); $i2 = Asido::Image('example.png', 'result_04_2.png'); /** * Resize the image by fitting it inside the 800x800 frame: in * fact it will not be resized because it is smaller */ Asido::Fit($i1, 800, 800); /** * Resize the image by fitting it inside the 400x400 frame: the image * will do be resized by making it fit inside the 400x400 "mold" */ Asido::Fit($i2, 400, 400); /** * Save the result */ $i1->Save(ASIDO_OVERWRITE_ENABLED); $i2->Save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
* Resize Example #02 * * This example shows how the proportional resize only by one dimension (width) works * * @filesource * @package Asido.Examples * @subpackage Asido.Examples.Resize */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ asido::driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = asido::image('example.png', 'result_02.png'); /** * Resize the image proportionally only by setting only the width, and the height will be corrected accordingly */ Asido::width($i1, 600); /** * Save the result */ $i1->save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////
* "white" is used to fill the blank areas. This is very handy when you want all * the resulting images to fit inside some frame without stretching them if the * proportions of the image and the frame do not match * * @filesource * @package Asido.Examples * @subpackage Asido.Examples.Resize */ ///////////////////////////////////////////////////////////////////////////// /** * Include the main Asido class */ include './../../class.asido.php'; /** * Set the correct driver: this depends on your local environment */ Asido::Driver('gd'); /** * Create an Asido_Image object and provide the name of the source * image, and the name with which you want to save the file */ $i1 = Asido::Image('example.png', 'result_05.png'); /** * Resize the image by putting it inside a square frame (300x300) with `rgb(177,77,37)` as background. */ Asido::Frame($i1, 300, 300, Asido::Color(39, 107, 20)); /** * Save the result */ $i1->Save(ASIDO_OVERWRITE_ENABLED); /////////////////////////////////////////////////////////////////////////////