Foros del Web » Programando para Internet » PHP »

Problema para redimensionar imagen

Estas en el tema de Problema para redimensionar imagen en el foro de PHP en Foros del Web. Tengo el siguiente scrip que he utilizado en varios sitios que he desarrollado, lo malo es que me encontre con un sitio donde no me ...
  #1 (permalink)  
Antiguo 03/09/2008, 01:33
Avatar de Capimaster  
Fecha de Ingreso: agosto-2004
Mensajes: 494
Antigüedad: 19 años, 8 meses
Puntos: 2
Problema para redimensionar imagen

Tengo el siguiente scrip que he utilizado en varios sitios que he desarrollado, lo malo es que me encontre con un sitio donde no me funciona... y no se que es lo que paso... ojala alguien sepa algo sobre esto..

el erro que me da es
Cita:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Mi script es..
Código PHP:
<?php 
$anchura
=200
$hmax=200
$nombre=basename($_GET['imagen']); 
$datos getimagesize($nombre); 
if(
$datos[2]==1){$img = @imagecreatefromgif($nombre);} 
if(
$datos[2]==2){$img = @imagecreatefromjpeg($nombre);} 
if(
$datos[2]==3){$img = @imagecreatefrompng($nombre);} 
$ratio = ($datos[0] / $anchura); 
$altura = ($datos[1] / $ratio); 
if(
$altura>$hmax){$anchura2=$hmax*$anchura/$altura;$altura=$hmax;$anchura=$anchura2;} 
$thumb imagecreatetruecolor($anchura,$altura); 
imagecopyresampled($thumb$img0000$anchura$altura$datos[0], $datos[1]); 
if(
$datos[2]==1){header("Content-type: image/gif"); imagegif($thumb);} 
if(
$datos[2]==2){header("Content-type: image/jpeg");imagejpeg($thumb);} 
if(
$datos[2]==3){header("Content-type: image/png");imagepng($thumb); } 
imagedestroy($thumb); 
?>
__________________
http://www.elcapitolio.com.mx - Ocotlán, Jalisco, México
  #2 (permalink)  
Antiguo 03/09/2008, 02:37
 
Fecha de Ingreso: agosto-2008
Mensajes: 3
Antigüedad: 15 años, 7 meses
Puntos: 0
Pregunta Respuesta: Problema para redimensionar imagen

Estas usando un servidor que tiene PHP instalado como cgi, corrígeme si me equivoco por que puedo confundirme al ver muy similar el error que te da con el error que me da el IPCop cuando modifico el código y me olvido de un punto o una coma (Error 500).

Por cierto si lo vas a usar para poner un fondo de pantalla optimiza el código:

Código PHP:
<?php // v5.0 - UTF-8 (áéíóú) / Update db Certified
session_start();
// Con esto evitamos que me hotlinkeen las imágenes de fondo
// index.php tiene un $_SESSION["index"] = true;
if (!$_SESSION["index"]) { header("Location: index.php"); exit(); }
unset(
$_SESSION["index"]);
// Cálculo inicial del código mas un porcentaje para evitar
// las bandas negras que aparecen a los laterales
$anchura $_GET["width"]+round($_GET["width"]/10.5,0);
$hmax $_GET["height"]+round($_GET["height"]/10.5,0);
// Directorio donde tengo las imagenes
$walls scandir("imgages/fondos/");
array_shift($walls); // Quitamos .
array_shift($walls); // Quitamos ..
$nombre "http://www.forosdelweb.com/images/fondos/".$walls[array_rand($walls)];
$datos getimagesize($nombre);
if( 
$datos[2] == 1) { $img = @imagecreatefromgif($nombre); }
if( 
$datos[2] == 2) { $img = @imagecreatefromjpeg($nombre); }
if( 
$datos[2] == 3) { $img = @imagecreatefrompng($nombre); }
$ratio = ($datos[0] / $anchura);
$altura = ($datos[1] / $ratio);
if(
$altura $hmax) {
    
$anchura2 $hmax*$anchura/$altura;
    
$altura $hmax;
    
$anchura $anchura2;
}
// Omito los resultados dados por que se queda pequeña por defecto
// al mantener el ratio de aspecto y como ahora Google Chrome
// maximiza el area de navegación queda mucho mejor así:
$anchura $_GET["width"];
$altura $_GET["height"];
// Debug
//$_SESSION["borrar"] = $_GET["width"]."x".$_GET["height"]." -> ".$anchura."x".$altura;
$thumb imagecreatetruecolor($anchura,$altura);
imagecopyresampled($thumb$img0000$anchura$altura$datos[0], $datos[1]);
if( 
$datos[2] == 1) { header("Content-type: image/gif"); imagegif($thumb); }
if( 
$datos[2] == 2) { header("Content-type: image/jpeg"); imagejpeg($thumb); }
if( 
$datos[2] == 3) { header("Content-type: image/png"); imagepng($thumb); }
imagedestroy($thumb);
?>
Quizá también lo que puede pasar es que no tenga gd, haz un phpinfo(); y postea.

Última edición por phaapron; 03/09/2008 a las 02:38 Razón: Faltaba phpinfo();
  #3 (permalink)  
Antiguo 03/09/2008, 06:20
Avatar de Capimaster  
Fecha de Ingreso: agosto-2004
Mensajes: 494
Antigüedad: 19 años, 8 meses
Puntos: 2
Cita:
PHP Version 5.2.5

System Linux ns.noctx7.net 2.6.18-53.el5 #1 SMP Mon Nov 12 02:22:48 EST 2007 i686
Build Date Apr 20 2008 01:52:00
Configure Command './configure' '--disable-pdo' '--enable-bcmath' '--enable-calendar' '--enable-force-cgi-redirect' '--enable-ftp' '--enable-libxml' '--enable-magic-quotes' '--enable-mbstring' '--enable-sockets' '--prefix=/usr' '--with-curl=/opt/curlssl/' '--with-gd' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr'
Server API CGI
Virtual Directory Support disabled
Configuration File (php.ini) Path /usr/lib
Loaded Configuration File /usr/local/lib/php.ini
PHP API 20041225
PHP Extension 20060613
Zend Extension 220060519
Debug Build no
Thread Safety disabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, data, http, ftp, compress.zlib
Registered Stream Socket Transports tcp, udp, unix, udg
Registered Stream Filters string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, convert.iconv.*, zlib.*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with the ionCube PHP Loader v3.1.32, Copyright (c) 2002-2007, by ionCube Ltd., and
with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
Cita:
gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XPM Support enabled
XBM Support enabled
MAs facil.... http://www.afamo.com.mx/phpinfo.php
__________________
http://www.elcapitolio.com.mx - Ocotlán, Jalisco, México

Última edición por GatorV; 03/09/2008 a las 08:26
  #4 (permalink)  
Antiguo 03/09/2008, 08:27
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Problema para redimensionar imagen

Revisa con tu host el error log que te da Apache, lo más seguro es que ahi se impriman los errores y así podras ver porque falla.

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:47.