function init($preferDrivers = array('gd', 'imagick2', 'imagick', 'magickwand')) { $alias = array('imagick2' => 'imagick2_ext', 'imagick' => 'imagick_ext', 'magickwand' => 'magick_wand'); reset($preferDrivers); foreach ($preferDrivers as $driver) { if (AriAsidoHelper::isExtensionLoaded(array($driver))) { if (array_key_exists($driver, $alias)) { $driver = $alias[$driver]; } asido::driver($driver); return true; } } return false; }
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']; }
/** Load Asido extensions **/ function aslMloadExtensions($drivers = array('imagick', 'gd', 'magickwand')) { $driverAliases = array('imagick' => 'imagick_ext', 'magickwand' => 'magick_wand'); reset($drivers); foreach ($drivers as $driver) { if (@extension_loaded($driver)) { if ($driver == 'imagick' && !function_exists('imagick_readImage')) { continue; } if (array_key_exists($driver, $driverAliases)) { $driver = $driverAliases[$driver]; } asido::driver($driver); return true; } } return false; }
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); /////////////////////////////////////////////////////////////////////////////
/** * Destroy the target for the provided temporary object * * @param Asido_TMP &$tmp * @return boolean * @access protected * @abstract */ function __destroy_target(&$tmp) { asido::trigger_abstract_error( __CLASS__, __FUNCTION__ ); }
/** * Store an operation to image's queue of operations * * @param Asido_Image &$image * @param string $operation * @param array $params * @return boolean * * @access private * @static */ function _operation(&$image, $operation, $params) { $d =& asido::_driver(); // no driver ? // if (!is_a($d, 'asido_driver')) { trigger_error('No Asido driver loaded', E_USER_WARNING); return false; } // not an image ? // if (!is_a($image, 'Asido_Image')) { trigger_error(sprintf('The image you are attempting to ' . ' \'%s\' ("%s") is not a ' . ' valid Asido image object', $operation, get_class($image)), E_USER_ERROR); return false; } // queue operation // $p = array_merge(array('tmp' => null), $params); $image->operation(array(&$d, $operation), $p); return true; }
* * 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); /////////////////////////////////////////////////////////////////////////////
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); } header("Content-Length: " . filesize($resized)); if ($format == "jpg") { header("Content-type: image/jpeg"); } else { header("Content-type: image/png"); } readfile($resized); } catch (Exception $e) { } exit;
<?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); /////////////////////////////////////////////////////////////////////////////
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'); if ($format == "png") @asido::convert($i1, 'image/png'); @$i1->save(ASIDO_OVERWRITE_ENABLED); } header("Content-Length: " . filesize($resized)); if ($format == 'jpg' || $format == 'jpeg') header("Content-type: image/jpeg"); elseif ($format == 'png') header("Content-type: image/png"); else header("Content-type: image/jpeg"); // TODO: log an error when a format is passed in which is unrecognized readfile($resized); } catch (Exception $e) { // TODO: Y U NO LOG SOMETHING HERE } exit();
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; }