Пример #1
0
 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;
 }
Пример #4
0
 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);
 }
Пример #5
0
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;
}
Пример #6
0
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'];
}
Пример #7
0
* 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);
/////////////////////////////////////////////////////////////////////////////
Пример #8
0
* 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);
/////////////////////////////////////////////////////////////////////////////
Пример #9
0
         // this is a horizontal image
         $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');
 }
Пример #10
0
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);
    }
}
Пример #11
0
 /**
  * @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;
 }