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']; }
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']; }
* 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); /////////////////////////////////////////////////////////////////////////////
} else { if (@is_readable($imagePath) && ($previewWidth > 0 || $previewHeight > 0 || strstr($convertImage, 'rotate')) && isset($autoGenerateThumbs) && $autoGenerateThumbs != 0) { if (!aslMisExtensionsLoaded()) { aslMloadExtensions(); } if (!aslMisExtensionsLoaded()) { $imagesCode .= JURI::root() . "{$path}/{$entry}' "; } else { $imagePathInfo = pathinfo($imagePath); $generatedThumbName = sprintf('%s_%s_%s.%s', md5('artsexythumb_' . $convertImage . $cropStart . $cropEnd . '_' . $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 ($convertImage == 'crop' && $previewWidth && $previewHeight) { if ($cropStart) { $cropStartArray = explode(',', $cropStart); if ($cropEnd) { $cropEndArray = explode(',', $cropEnd); Asido::crop($img, $cropStartArray[0], $cropStartArray[1], $cropEndArray[0], $cropEndArray[1]); } else { Asido::crop($img, $cropStartArray[0], $cropStartArray[1], $previewWidth, $previewHeight); } } else { Asido::crop($img, 0, 0, $previewWidth, $previewHeight); } } else { if ($convertImage == 'crop_resize' && $previewWidth && $previewHeight) { $imgSize = getimagesize($imagePath);
* * 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); /////////////////////////////////////////////////////////////////////////////
$crop_width = $original_height; $crop_start_x = $original_width / 2 - $crop_width / 2; $crop_start_y = 0; } else { // this is a vertical image $crop_width = $original_width; $crop_start_y = $original_height / 2 - $crop_width / 2; $crop_start_x = 0; } } set_include_path(get_include_path() . PATH_SEPARATOR . $basepath . "/modules/bolts/lib"); set_include_path(get_include_path() . PATH_SEPARATOR . $config['application']['asido_path']); define('ASIDO_DIR', null); @(include 'class.asido.php'); @asido::driver('gd_c'); $i1 = @asido::image($image, $resized); if ($crop) { @asido::Crop($i1, $crop_start_x, $crop_start_y, $crop_width, $crop_width); @asido::width($i1, $max_width); } else { if ($max_height > 0) { $use_height = $max_height; } else { $use_height = 1000; } @asido::fit($i1, $max_width, $use_height); } if ($format == "jpg") { @asido::convert($i1, 'image/jpeg'); } @$i1->save(ASIDO_OVERWRITE_ENABLED);
<?php /** * Convert Example #01 * * This example shows how the convert works without explicitly declaring it but * only using the extension of the filename of the "result" image (result_01.gif) * * @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_01.gif'); /** * 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; } } } }
function Renderwatermark($tempname, $folder) { include_once 'core/asido/class.asido.php'; asido::driver('gd'); if (CONF_PUT_WATERMARK && file_exists("data/" . CONF_WATERMARK_IMAGE)) { $i = asido::image($folder . $tempname, $folder . $tempname); asido::watermark($i, "data/" . CONF_WATERMARK_IMAGE, ASIDO_WATERMARK_BOTTOM_CENTER, ASIDO_WATERMARK_SCALABLE_ENABLED); $i->save(ASIDO_OVERWRITE_ENABLED); } }
/** * @function: makeAvatar * @type: Public * @description: Преоразмерява каченото изображение с размери 200x200 */ public function makeAvatar($student, $filename, $file_ext) { require_once ROOT_PATH . 'libs/asido/class.asido.php'; asido::driver('gd'); mt_srand(); $orig = HTDOCS . "uploads/" . $filename; //път до качената картинка $tmpthumb = HTDOCS . "avatars/" . $student . $file_ext; //път до тъмбнейла if (!copy($orig, $tmpthumb)) { return false; } if (!($th = asido::image($tmpthumb, $tmpthumb))) { return false; } asido::stretch($th, 200, 200, ASIDO_RESIZE_STRETCH); $th->save(ASIDO_OVERWRITE_ENABLED); return true; }