Bien, las ideas las tenia todas pero aun no me salen
mi archivo rotar_foto_preview.php:
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");
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 );
}
ob_start();
imagejpeg($dst_img,'',100);
$binario_contenido = ob_get_contents();
//ob_end_clean();
header("Location: rotar_imagen.php?id=".$_GET['id']);
exit;
?>
Mi archivo rotar_imagen:
Código PHP:
<?
include('../inc/conect.php');
global $binario_contenido; // ESTE VALOR NO LO ESTA OBTENIENDO
$id = $_GET['id'];
$consulta_update = "UPDATE archivos SET archivo_binario = '$binario_contenido'";
mysql_query($consulta_update,$db_conn) or die("No se pudo actuzalizar los datos en la base de datos.");
$sql = "SELECT archivo_binario,archivo_tipo FROM archivos WHERE id='".$_GET['id']."'";
$consulta2 = mysql_query($sql,$db_conn);
$datos = mysql_result($consulta2,0,"archivo_binario");
$tipo = mysql_result($consulta2,0,"archivo_tipo");
header("Content-type: $tipo");
echo $datos;
?>
en este segundo archivo aparece de nuevo la variable $binario_contendo, el cual he tratado de varias formas pasar su valor al archivo pero no he podido como lo podria hacer??, y alguna idea para poder hacer el previe sin tener k grabar