EnglishFrançais
Membres
Website creation arrow Forum

Forum création site web (inscription requise pour poster)

 
kmchen
Moderator

Moderator
Posts: 9
graphgraph
Karma: 0  
Click here to see the profile of this user
gd-png: fatal libpng error: zlib error in - 2007/12/20 23:48 Lorsque je charge des png dans adsmanager j'obtiens le message d'erreur:

Fatal error: imagepng() [<a href='function.imagepng'>function.imagepng</a>]: gd-png: fatal libpng error: zlib error in /home/maxime/www/components/com_adsmanager/adsmanager.php on line 931
  The administrator has disabled public write access.
kmc
Admin

Admin
Posts: 15
graph
Karma: 0  
Click here to see the profile of this user
Re:gd-png: fatal libpng error: zlib error in - 2007/12/20 23:57 ADSMANAGER n'est pas compatible avec la dernière installation de PHP5 qui introduit la notion de qualité dans la fonction imagepng.
Il faut patcher le composant comme suit dans le fichier adsmanager.php (les lignes ajoutées ou modifiées sont signalées par le commentaire //kmc_:

function createImageAndThumb($src_file,$image_name,$thumb_name,
$max_width,
$max_height,
$max_width_t,
$max_height_t,
$tag,
$path,
$orig_name)
{
global $mosConfig_absolute_path;

$types = array(
IMAGETYPE_JPEG => 'jpeg',
IMAGETYPE_GIF => 'gif',
IMAGETYPE_PNG => 'png'
);

ini_set('memory_limit', '20M');


$src_file = urldecode($src_file);
/*if (extension_loaded('exif'))
{
$type2 = exif_imagetype($src_file);
$types = array(
IMAGETYPE_JPEG => 'jpeg',
IMAGETYPE_GIF => 'gif',
IMAGETYPE_PNG => 'png'
);

$type = $types[$type2];
}
else
{*/
$quality=75; //kmc_acp
$orig_name = strtolower($orig_name);
$findme = '.jpg';
$pos = strpos($orig_name, $findme);
if ($pos === false)
{
$findme = '.jpeg';
$pos = strpos($orig_name, $findme);
if ($pos === false)
{
$findme = '.gif';
$pos = strpos($orig_name, $findme);
if ($pos === false)
{
$findme = '.png';
$pos = strpos($orig_name, $findme);
if ($pos === false)
{
return;
}
else
{
$type = "png";
$quality = 9; //kmc_acp
}
}
else
{
$type = "gif";
}
}
else
{
$type = "jpeg";
}
}
else
{
$type = "jpeg";
}
//}

$max_h = $max_height;
$max_w = $max_width;
$max_thumb_h = $max_height_t;
$max_thumb_w = $max_width_t;

if ( file_exists( "$path/$image_name")) {
unlink( "$path/$image_name");
}

if ( file_exists( "$path/$thumb_name")) {
unlink( "$path/$thumb_name");
}

$read = 'imagecreatefrom' . $type;
$write = 'image' . $type;

$src_img = $read($src_file);

// height/width
$imginfo = getimagesize($src_file);
$src_w = $imginfo[0];
$src_h = $imginfo[1];

$zoom_h = $max_h / $src_h;
$zoom_w = $max_w / $src_w;
$zoom = min($zoom_h, $zoom_w);
$dst_h = $zoom<1 ? round($src_h*$zoom) : $src_h;
$dst_w = $zoom<1 ? round($src_w*$zoom) : $src_w;

$zoom_h = $max_thumb_h / $src_h;
$zoom_w = $max_thumb_w / $src_w;
$zoom = min($zoom_h, $zoom_w);
$dst_thumb_h = $zoom<1 ? round($src_h*$zoom) : $src_h;
$dst_thumb_w = $zoom<1 ? round($src_w*$zoom) : $src_w;

$dst_img = imagecreatetruecolor($dst_w,$dst_h);

$white = imagecolorallocate($dst_img,255,255,255);
imagefill($dst_img,0,0,$white);
imagecopyresampled($dst_img,$src_img, 0,0,0,0, $dst_w,$dst_h,$src_w,$src_h);
$textcolor = imagecolorallocate($dst_img, 255, 255, 255);
if (isset($tag))
imagestring($dst_img, 5, 5, 5, "$tag", $textcolor);
//kmc_m1p $desc_img = $write($dst_img,"$path/$image_name", $quality);
$desc_img = $write($dst_img,"$path/$image_name", $quality);


$dst_t_img = imagecreatetruecolor($dst_thumb_w,$dst_thumb_h);
$white = imagecolorallocate($dst_img,255,255,255);
imagefill($dst_t_img,0,0,$white);
imagecopyresampled($dst_t_img,$src_img, 0,0,0,0, $dst_thumb_w,$dst_thumb_h,$src_w,$src_h);
$textcolor = imagecolorallocate($dst_t_img, 255, 255, 255);
if (isset($tag))
imagestring($dst_t_img, 2, 2, 2, "$tag", $textcolor);
//kmc_m1p $desc_img = $write($dst_t_img,"$path/$thumb_name", $quality);
$desc_img = $write($dst_t_img,"$path/$thumb_name", $quality);

}
  The administrator has disabled public write access.