Ver Mensaje Individual
  #2 (permalink)  
Antiguo 04/09/2008, 13:41
Sevillo
 
Fecha de Ingreso: noviembre-2005
Ubicación: Venezuela
Mensajes: 56
Antigüedad: 18 años, 6 meses
Puntos: 0
Respuesta: Imagenes PHP, Mysql, Flash

Anexo el codigo php que convierte el String de Flash

<?php
//If GD library is not installed, say sorry
if(!function_exists("imagecreate")) die("No se puede mostrar la foto");
//Capture Post data
$data = explode(",", $_GET['img']);
//echo $data;
$width = $_GET['width'];
$height = $_GET['height'];
//Allocate image
$image=(function_exists("imagecreatetruecolor"))?i magecreatetruecolor( $width ,$height ):imagecreate( $width ,$height );
$background = imagecolorallocate( $image ,0 , 0 , 0 );
//Copy pixels
$i = 0;
for($x=0; $x<=$width; $x++){
for($y=0; $y<=$height; $y++){
$r = 255-hexdec("0X".substr( $data[$i] , 0 , 2 ));
$g = 255-hexdec("0x".substr( $data[$i] , 2 , 2 ));
$b = 255-hexdec("0x".substr( $data[$i++] , 4 , 2 ));
$color = ($r << 16) | ($g << 8) | $b;
imagesetpixel ( $image , $x , $y , $color );
}
}
//Output image and clean
//$mime = "MIME";
//header( "Content-Type: $mime" );
//echo $image;
header( "Content-type: image/jpeg" );
imagejpeg( $image );
//$in = imagecreatefromjpeg($editDirectory.$imageName);
imagejpeg( $image , "./foto.jpg", 100) or die("Cant save image");
imagedestroy( $image );
//ImageJPEG( $image );
//imagedestroy( $image );

function createThumbnail($img, $imgPath, $suffix, $newWidth, $newHeight, $quality)
{
// Open the original image.
$original = imagecreatefromjpeg("$imgPath/$img") or die("Error Opening original");
list($width, $height, $type, $attr) = getimagesize("$imgPath/$img");

// Resample the image.
$tempImg = imagecreatetruecolor($newWidth, $newHeight) or die("Cant create temp image");
imagecopyresized($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height) or die("Cant resize copy");

// Create the new file name.
$newNameE = explode(".", $img);
$newName = ~T. $newNameE[0] .~T. $suffix .~Q.~R. $newNameE[1] .~T;

// Save the image.
imagejpeg($tempImg, "$imgPath/$newName", $quality) or die("Cant save image");

// Clean up.
imagedestroy($original);
imagedestroy($tempImg);
return true;
}

?>