Funciona bien el unico problema esta en lo que decia Cluster de al querer guardarla de nuevo en la DB se me ha heacho un imposible
Código PHP:
<?php
include('../inc/conect.php');
$sql = "SELECT archivo_binario,archivo_tipo,archivo_nombre FROM archivos WHERE id='".$_GET['id']."'";
$consulta = mysql_query($sql,$db_conn);
$imagen = mysql_result($consulta,0,"archivo_binario");
// Envio cabeceras al navegador .. se indica que lo "que vá" es una imagen de formato MIME JPEG
//echo "<a href=\"rotar_imagen?id=".$_GET['id']."&angulo=".$_GET['angulo']."&accion=guardar\">Guardar</a>";
Header ("Content-type: image/jpeg");
$imgSrc= imagecreatefromstring($imagen);
$dst_img=ImageRotateRightAngle($imgSrc, $_GET['angulo']);
// $imgSrc - GD image handle of source image
// $angle - angle of rotation. Needs to be positive integer
// angle shall be 0,90,180,270, but if you give other it
// will be rouned to nearest right angle (i.e. 52->90 degs,
// 96->90 degs)
// returns GD image handle of rotated image.
// la llamada a la función
// Primero tendrás que hacer una consulta a tu BD para obtener la imagen . .es igual el código que ver_thumbnail.php
function ImageRotateRightAngle( $imgSrc, $angle )
{
// ensuring we got really RightAngle (if not we choose the closest one)
$angle = min( ( (int)(($angle+45) / 90) * 90), 270 );
// no need to fight
if( $angle == 0 )
return( $imgSrc );
// dimenstion of source image
$srcX = imagesx( $imgSrc );
$srcY = imagesy( $imgSrc );
switch( $angle )
{
case 90:
$imgDest = imagecreatetruecolor( $srcY, $srcX );
for( $x=0; $x<$srcX; $x++ )
for( $y=0; $y<$srcY; $y++ )
imagecopy($imgDest, $imgSrc, $srcY-$y-1, $x, $x, $y, 1, 1);
break;
case 180:
$imgDest = ImageFlip( $imgSrc, IMAGE_FLIP_BOTH );
break;
case 270:
$imgDest = imagecreatetruecolor( $srcY, $srcX );
for( $x=0; $x<$srcX; $x++ )
for( $y=0; $y<$srcY; $y++ )
imagecopy($imgDest, $imgSrc, $srcY-$y-1, $srcX-$x-1, $x, $y, 1, 1);
break;
}
return( $imgDest );
}
$imagen_volteada = imagejpeg($dst_img,'',100);
imagejpeg($dst_img,'',100);
?>
<a href="?id=<?=$_GET['id']?>&angulo<?=$_GET['angulo']?>&accion=guardar"> GUARDAR </a> //Aqui es que esta el problema, el link no me aparece debido a que el header() es de jpg,
<?php
if($_GET['accion'] == "guardar"){
global $imagen_volteada;
$binario_contenido = addslashes(fread(fopen($imagen_volteada, "r"), filesize($imagen_volteada)));
$binario_peso=$_FILES[$imagen_volteada]['size'];
$binario_tipo=$_FILES[$imagen_volteada]['type'];
$consulta_insertar = "INSERT INTO archivos (archivo_binario,archivo_peso,archivo_tipo) VALUES ('$binario_contenido','$binario_peso', '$binario_tipo')";
mysql_query($consulta_insertar,$db_conn) or die("No se pudo insertar los datos en la base de datos.");
}
?>
Bien mi problema lo puse en comentario y es que el link que pongo para poder guardar la imagen rotada, no me aparece porque el header es de jpg,...
no se puede enviar header tantos jpg como para texto para que funcionen, no entiendo mucho lo de lo headers, lo unico que se es que me funcionan para redirecionar con lo de header("Location:..."), pero bueh que debo hacer para poder guardar en la db?