Warning: imagepng() [function.imagepng]: gd-png: fatal libpng error: zlib failed to initialize compressor -- stream error in /mnt/web7/32/27/51920027/htdocs/coriaweb/artistas/jacobo/redimensionar.php on line 36
Warning: imagepng() [function.imagepng]: gd-png error: setjmp returns error condition in /mnt/web7/32/27/51920027/htdocs/coriaweb/artistas/jacobo/redimensionar.php on line 36
Se trata de que cuando subo imagenes PNG me da el error pero no en todas la png solo en algunas, (las que le da la gana), buscando por el foro encontre una solucion a mi codigo ,mi codigo es este:
Código PHP:
<?php
function crearThumb( $fuente, $destino, $dim=120, $propor=false, $forzar=false ) {
$tipo_imagen = explode( ".", $fuente );
$sizeof = count( $tipo_imagen ) - 1;
$ext = strtolower( $tipo_imagen[$sizeof] );
if ( $ext == "gif" ) {
$fuenteimg = @imagecreatefromgif( $fuente );
}
elseif ( $ext == "png" ) {
$fuenteimg = @imagecreatefrompng( $fuente );
}
else {
$fuenteimg = @imagecreatefromjpeg( $fuente );
}
list( $ancho, $alto, $tipo, $atr ) = getimagesize( $fuente );
if ( $ancho > $dim || $alto > $dim || $forzar ) {
if ( $propor ) {
if ( $ancho > $alto ) {
$nAncho = $dim;
$nAlto = $dim/( $ancho/$alto );
} else {
$nAlto = $dim;
$nAncho = $dim/( $alto/$ancho );
}
} else {
$nAncho = $dim;
$nAlto = $dim;
}
$thumb = imagecreatetruecolor( $nAncho, $nAlto );
imagecopyresampled( $thumb, $fuenteimg, 0, 0, 0, 0, $nAncho, $nAlto, $ancho, $alto );
$calidad = 100;
if ( $ext == "gif" ) {
imagegif( $thumb, $destino, $calidad);
}
elseif ( $ext == "png" ) {
imagepng( $thumb, $destino, $calidad);
}
else {
imagejpeg( $thumb, $destino, $calidad);
}
}
}
?>
¿Algun modo de solucionarlo?