[svn r18939] Minor - Fixed warnings when you migrate user's picture to dokeos 1.8.6 - see FS#3510

skala
Cristian Fasanando 17 years ago
parent 125acc982f
commit 1bcb725e22
  1. 40
      main/inc/lib/image.lib.php
  2. 5
      main/install/update-db-1.8.5-1.8.6.inc.php

@ -20,15 +20,15 @@ class image {
}
function createimagefromtype($file,$handler) {
$size = getimagesize($file);
$size = @getimagesize($file);
$type=$size[2];
switch ($type) {
case 2 : $imhandler = imagecreatefromjpeg($file);
case 2 : $imhandler = @imagecreatefromjpeg($file);
break;
case 3 : $imhandler = imagecreatefrompng($file);
case 3 : $imhandler = @imagecreatefrompng($file);
break;
case 1 : $imhandler = imagecreatefromgif($file);
case 1 : $imhandler = @imagecreatefromgif($file);
break;
}
@ -53,44 +53,44 @@ class image {
$height = (int)($size[1]*$scale);
$deltaw = (int)(($thumbw - $width)/2);
$deltah = (int)(($thumbh - $height)/2);
$dst_img = ImageCreateTrueColor($thumbw, $thumbh);
$dst_img = @ImageCreateTrueColor($thumbw, $thumbh);
if ( !empty($this->color))
imagefill ( $dst_img, 0, 0, $this->color );
@imagefill ( $dst_img, 0, 0, $this->color );
$this->bgx=$thumbw;
$this->bgy=$thumbh;
}
elseif ($border==0) {
$scale = min($thumbw/$size[0], $thumbh/$size[1]);
$scale = ($size[0] > 0 && $size[1] >0)?min($thumbw/$size[0], $thumbh/$size[1]):0;
$width = (int)($size[0]*$scale);
$height = (int)($size[1]*$scale);
$deltaw = 0;
$deltah = 0;
$dst_img = ImageCreateTrueColor($width, $height);
$dst_img = @ImageCreateTrueColor($width, $height);
$this->bgx=$width;
$this->bgy=$height;
}
$src_img = $this->bg;
ImageCopyResampled($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img),ImageSY($src_img));
@ImageCopyResampled($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img),ImageSY($src_img));
$this->bg=$dst_img;
imagedestroy($src_img);
@imagedestroy($src_img);
}
function addbackground($bgfile) {
if ( !empty($bgfile) && file_exists($bgfile) ) { $this->bg = image::createimagefromtype($bgfile,'bg');
imagealphablending( $this->bg ,TRUE );
@imagealphablending( $this->bg ,TRUE );
}
}
function addlogo($file) {
$this->logo = image::createimagefromtype($file,'logo');
imagealphablending( $this->logo ,TRUE );
@imagealphablending( $this->logo ,TRUE );
$size = getimagesize($file);
$this->logox=$size[0];
$this->logoy=$size[1];
@ -100,11 +100,11 @@ class image {
function mergelogo($x,$y,$alpha=100) {
if ($x<0) $x=$this->bgx-$this->logox+$x;
if ($y<0) $y=$this->bgy-$this->logoy+$y;
return imagecopymerge ( $this->bg, $this->logo, $x, $y, 0, 0, $this->logox, $this->logoy, $alpha );
return @imagecopymerge ( $this->bg, $this->logo, $x, $y, 0, 0, $this->logox, $this->logoy, $alpha );
}
function makecolor($red, $green, $blue) {
$this->color = imagecolorallocate( $this->bg, $red, $green, $blue );
$this->color = @imagecolorallocate( $this->bg, $red, $green, $blue );
}
function setfont($fontfile) {
@ -116,7 +116,7 @@ class image {
$this->fontfile='verdana';
$text= preg_replace('`(?<!\r)\n`',"\r\n",$text);
$box=imagettfbbox ( $size, $angle, $this->fontfile, $text );
$box=@imagettfbbox ( $size, $angle, $this->fontfile, $text );
if ($x<0) {
$x=$this->bgx - max($box[2],$box[4]) + $x;
} else {
@ -128,7 +128,7 @@ class image {
$y=max(-$box[7],-$box[5]) + $y;
}
imagettftext($this->bg, $size, $angle, $x, $y, $this->color, $this->fontfile , $text );
@imagettftext($this->bg, $size, $angle, $x, $y, $this->color, $this->fontfile , $text );
}
@ -143,20 +143,20 @@ class image {
case 'PNG' :
if (!$file) header("Content-type: image/png");
if ($compress!=-1)
imagetruecolortopalette ( $this->bg, true, $compress);
@imagetruecolortopalette ( $this->bg, true, $compress);
return imagepng($this->bg,$file,$compress);
break;
case 'GIF' :
if (!$file) header("Content-type: image/gif");
if ($compress!=-1)
imagetruecolortopalette ( $this->bg, true, $compress);
@imagetruecolortopalette ( $this->bg, true, $compress);
return imagegif($this->bg,$file,$compress);
break;
default: return 0;
}
imagedestroy($this->bg);
imagedestroy($this->logo);
@imagedestroy($this->bg);
@imagedestroy($this->logo);
}

@ -1,4 +1,4 @@
<?php // $Id: update-db-1.8.5-1.8.6.inc.php 18697 2009-02-25 16:55:11Z cfasanando $
<?php // $Id: update-db-1.8.5-1.8.6.inc.php 18939 2009-03-10 22:29:24Z cfasanando $
/* See license terms in /dokeos_license.txt */
/**
==============================================================================
@ -181,7 +181,6 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
}
if (file_exists($image_repository)) {
chmod($image_repository, 0777);
chmod($dir.$user_id, 0777);
if (is_dir($dir.$user_id)) {
$picture_location = $dir.$user_id.'/'.$file;
@ -196,7 +195,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
$thumbwidth=150;
}
$new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]);
$new_height = ($picture_infos[0] > 0)?round(($thumbwidth/$picture_infos[0])*$picture_infos[1]) : 0;
$temp->resize($thumbwidth,$new_height,0);

Loading…
Cancel
Save