Probe quitando a "imagecolorallocate" sus atributos pero sigue mostrando colores distintos al original
Espero puedan ver el error. Gracias !
Código PHP:
<?php
if($_GET['width'] > 0) {
$width = $_GET['width'];
} else
{
$width = 400;
}
if($_GET['height'] > 0) {
$height = $_GET['height'];
} else
{
$height = 350;
}
if($_GET['filename']) {
$filename = $_GET['filename'];
} else
{
$filename = 'foto_silla2.jpg';
}
//imagen desde el archivo jpg
$src_image = imagecreatefromjpeg($filename);
$image = imagecreate($width, $height);
//asignamos los colores que ocuparemos más adelante
$bg = imagecolorallocate($image, 200, 200, 200);
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 100, 100, 100);
$margin_x = 10;
$margin_y = 10;
$w = $width-2*$margin_x;
$h = $height-2*$margin_y;
$src_w = imagesx($src_image);
$src_h = imagesy($src_image);
//¿desplegamos la imagen en la dimensión original?
if(($w > $src_w) && ($h > $src_h)) {
$dst_w = $src_w;
$dst_h = $src_h;
} else
//¿o escalamos la imagen de acuerdo a la dimensión horizontal?
if(($w/$h) < ($src_w/$src_h)) {
$dst_w = $w;
$dst_h = $w*$src_h/$src_w;
} else
//¿o la escalamos de acuerdo a la dimensión vertical?
{
$dst_w = $h*$src_w/$src_h;
$dst_h = $h;
}
imagecopyresized($image, $src_image, ($width-$dst_w)/2, ($height-$dst_h)/2,
0, 0, $dst_w, $dst_h, $src_w, $src_h);
//colocamos el texto sobre la imagen
//imagestring($image, 0, $margin_x, ($height-$margin_y), $filename, $white);
//encabezado correspondiente para los datos de salida
header("Content-type: image/jpeg");
//generamos la imagen
imagejpeg($image);
//liberamos la memoria
imagedestroy($image);
?>