Пример #1
0
 function _commit_crop_thumbnail($real_sizes)
 {
     $target_path = AMP_image_path($this->_model->getName(), AMP_IMAGE_CLASS_CROP);
     #AMP_mkdir( substr( $target_path, 0, strlen( $target_path ) - strlen( $this->_model->getName() - 1)));
     AMP_mkdir(dirname($target_path));
     $new_image =& $this->_model->crop($real_sizes['start_x'], $real_sizes['start_y'], $real_sizes['start_x'] + $real_sizes['width'], $real_sizes['start_y'] + $real_sizes['height']);
     if (!$new_image) {
         return $this->_commit_crop_failure();
     }
     $this->_model->write_image_resource($new_image, $target_path);
     $cropped_image = new AMP_System_File_Image($target_path);
     if (!$cropped_image->width) {
         return $this->_commit_crop_failure();
     }
     $target_path = AMP_image_path($this->_model->getName(), AMP_IMAGE_CLASS_THUMB);
     $thumb_ratio = AMP_IMAGE_WIDTH_THUMB / $cropped_image->width;
     $thumb_sizes = $this->_resize_ratio(array('height' => $cropped_image->height, 'width' => $cropped_image->width), $thumb_ratio);
     $thumb_image =& $cropped_image->resize($thumb_sizes['width'], $thumb_sizes['height']);
     if (!$thumb_image) {
         return $this->_commit_crop_failure(AMP_TEXT_THUMBNAIL);
     }
     $cropped_image->write_image_resource($thumb_image, $target_path);
     $renderer = new AMPDisplay_HTML();
     $this->message($renderer->image(AMP_image_url($this->_model->getName(), AMP_IMAGE_CLASS_CROP), array('border' => 1)) . $renderer->newline(2) . sprintf(AMP_TEXT_DATA_SAVE_SUCCESS, $cropped_image->getName() . $renderer->space() . AMP_TEXT_CROP), $this->_unique_action_key(), $this->_model->get_url_edit());
     return true;
 }
Пример #2
0
 function setImageFile($filename)
 {
     if (!file_exists($filename)) {
         return false;
     }
     $image_ref = new AMP_System_File_Image($filename);
     if (array_search($image_ref->get_mimetype(), $this->_allowed_mimetypes) === FALSE) {
         $this->addError(AMP_TEXT_ERROR_IMAGE_NOT_ALLOWED);
         return false;
     }
     $this->_paths = array(AMP_IMAGE_CLASS_OPTIMIZED => AMP_image_path($image_ref->getName(), AMP_IMAGE_CLASS_OPTIMIZED), AMP_IMAGE_CLASS_THUMB => AMP_image_path($image_ref->getName(), AMP_IMAGE_CLASS_THUMB), AMP_IMAGE_CLASS_ORIGINAL => AMP_image_path($image_ref->getName(), AMP_IMAGE_CLASS_ORIGINAL), AMP_IMAGE_CLASS_CROP => AMP_image_path($image_ref->getName(), AMP_IMAGE_CLASS_CROP));
     $image_ref->getFilename();
     $this->_image_ref =& $image_ref;
     $this->_initCrop();
     $this->_setWidths();
     return true;
 }