示例#1
0
文件: image.php 项目: nemein/openpsa
 public function generate_image($type, $filter_chain)
 {
     try {
         $original = new midcom_db_attachment($this->attachment);
     } catch (midcom_error $e) {
         $e->log();
         return false;
     }
     $found_derived = false;
     try {
         $derived = new midcom_db_attachment($this->{$type});
         $found_derived = true;
     } catch (midcom_error $e) {
         $derived = new midcom_db_attachment();
         $derived->parentguid = $original->parentguid;
         $derived->title = $original->title;
         $derived->mimetype = $original->mimetype;
         $derived->name = $type . '_' . $original->name;
     }
     $imagefilter = new midcom_helper_imagefilter($original);
     if (!$imagefilter->process_chain($filter_chain)) {
         throw new midcom_error('Image processing failed');
     }
     if (!$found_derived) {
         if (!$derived->create()) {
             throw new midcom_error('Failed to create derived image: ' . midcom_connection::get_error_string());
         }
         $this->{$type} = $derived->id;
         $this->update();
     }
     return $imagefilter->write($derived);
 }
示例#2
0
文件: video.php 项目: nemein/openpsa
 /**
  * Overwrites image content from file, recalculates size etc
  *
  * @param string $identifier image identifier to update
  * @param string $file file to use
  * @return boolean indicating success/failure
  */
 function update_image_from_file($identifier, $file)
 {
     if (!$this->_filter->write($this->attachments[$identifier])) {
         return false;
     }
     // Failing these is bad, but it's too late now that we already have overwritten the actual image data...
     $this->_set_attachment_info_additional($identifier, $file);
     $this->_update_attachment_info($identifier);
     return true;
 }