Пример #1
0
/////////////////////////////////////////////////////////////////////////////
/**
* 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);
/////////////////////////////////////////////////////////////////////////////
Пример #2
0
 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;
     }
 }