Beispiel #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;
 }