More fixes in the Image class #2664

skala
Julio Montoya 14 years ago
parent ed4db6cd58
commit c3a6ca5d55
  1. 2
      main/inc/lib/image.lib.php
  2. 26
      main/newscorm/openoffice_presentation.class.php

@ -85,7 +85,7 @@ class ImagickWrapper extends ImageWrapper {
if ($this->image) {
$this->fill_image_info(); //Fills height, width and type
}
if ($debug) error_log('set_image_wrapper loaded');
if ($this->debug) error_log('set_image_wrapper loaded');
} catch(ImagickException $e) {
if ($this->debug) error_log($e->getMessage());
}

@ -70,25 +70,19 @@ class OpenofficePresentation extends OpenofficeDocument {
$pattern = '/(\w+)\.png$/';
$replacement = '${1}_thumb.png';
$thumb_name = preg_replace($pattern, $replacement, $file_name);
// Calculate thumbnail size.
list($width, $height) = getimagesize($image);
$image_size = api_getimagesize($image);
$width = $image_size['width'];
$height = $image_size['height'];
$thumb_width = 300;
$thumb_height = floor($height * ($thumb_width / $width));
// Load.
$thumb = imagecreatetruecolor($thumb_width, $thumb_height);
$source = imagecreatefrompng($image);
// Resize.
imagecopyresized($thumb, $source, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
// Output.
imagepng($thumb, $this->base_work_dir.$this->created_dir .'/'. $thumb_name);
/*
// New resizing method using imagemagick.
$im = new Imagick($image);
$im->thumbnailImage($thumb_width, $thumb_height);
//file_put_contents($this->base_work_dir.$this->created_dir .'/'. $thumb_name, $im);
$im->writeImage($this->base_work_dir.$this->created_dir .'/'. $thumb_name);
*/
$my_new_image = Image($image);
$my_new_image->resize($thumb_width, $thumb_height);
$my_new_image->send_image($this->base_work_dir.$this->created_dir .'/'. $thumb_name, -1, 'png');
// Adding the thumbnail to documents.
$document_id_thumb = add_document($_course, $this->created_dir.'/'.urlencode($thumb_name), 'file', filesize($this->base_work_dir.$this->created_dir.'/'.$thumb_name), $slide_name);
api_item_property_update($_course, TOOL_THUMBNAIL, $document_id_thumb, 'DocumentAdded', api_get_user_id(), 0, 0);

Loading…
Cancel
Save