elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  guardar imagen
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: guardar imagen  (Leído 1,790 veces)
kakashi20


Desconectado Desconectado

Mensajes: 435


Ver Perfil
guardar imagen
« en: 18 Septiembre 2012, 06:21 am »

hola tengo este codigo en php para guardar una imagen pero el problema es que la instruccion header al usarla no deja escribir ningun texto para ser mostrado en la web:

<?php
session_start();
$usuario = $_SESSION['usuario_d'];
$destino = "images/".$usuario."/nueva.jpg";
$res = json_decode(stripslashes($_POST['jsondata']), true);
/* get data */
$count_images = count($res['images']);
/* the background image is the first one */
$background    = $res['images'][0]['src'];
$photo1       = imagecreatefromjpeg($background);
$foto1W       = imagesx($photo1);
$foto1H       = imagesy($photo1);
$photoFrameW    = $res['images'][0]['width'];
$photoFrameH    = $res['images'][0]['height'];
$photoFrame    = imagecreatetruecolor($photoFrameW,$photoFrameH);
imagecopyresampled($photoFrame, $photo1, 0, 0, 0, 0, $photoFrameW, $photoFrameH, $foto1W, $foto1H);

/* the other images */
for($i = 1; $i < $count_images; ++$i){
   $insert       = $res['images'][$i]['src'];
   $photoFrame2Rotation = (180-$res['images'][$i]['rotation']) + 180;
   
   $photo2       = imagecreatefrompng($insert);
   
   $foto2W       = imagesx($photo2);
   $foto2H       = imagesy($photo2);
   $photoFrame2W   = $res['images'][$i]['width'];
   $photoFrame2H    = $res['images'][$i]['height'];

   $photoFrame2TOP = $res['images'][$i]['top'];
   $photoFrame2LEFT= $res['images'][$i]['left'];

   $photoFrame2    = imagecreatetruecolor($photoFrame2W,$photoFrame2H);
   $trans_colour    = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
   imagefill($photoFrame2, 0, 0, $trans_colour);

   imagecopyresampled($photoFrame2, $photo2, 0, 0, 0, 0, $photoFrame2W, $photoFrame2H, $foto2W, $foto2H);
   
   $photoFrame2    = imagerotate($photoFrame2,$photoFrame2Rotation, -1,0);
   /*after rotating calculate the difference of new height/width with the one before*/
   $extraTop      =(imagesy($photoFrame2)-$photoFrame2H)/2;
   $extraLeft      =(imagesx($photoFrame2)-$photoFrame2W)/2;

   imagecopy($photoFrame, $photoFrame2,$photoFrame2LEFT-$extraLeft, $photoFrame2TOP-$extraTop, 0, 0, imagesx($photoFrame2), imagesy($photoFrame2));   
}
// Set the content type header - in this case image/jpeg


header('Content-type: image/jpeg');
imagejpeg($photoFrame,$destino,100);
imagejpeg($photoFrame);
imagedestroy($photoFrame);

?> 



si alguien me pudiese ayudar se lo agradeceria


En línea

дٳŦ٭
GNU/Linux Infrastructure Specialist
Ex-Staff
*
Desconectado Desconectado

Mensajes: 5.110


Ver Perfil WWW
Re: guardar imagen
« Respuesta #1 en: 21 Septiembre 2012, 01:17 am »

Si mandas texto antes del header te va a tronar, y más porque estás devilviendo una imagen. Pasa igual con las cookies.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
guardar imagen
Programación Visual Basic
Malkavian_71 1 1,811 Último mensaje 5 Octubre 2005, 06:05 am
por Slasher-K
Guardar una imagen redimensionada en un carpeta del pc
Java
d!lan 0 1,749 Último mensaje 4 Marzo 2014, 03:10 am
por d!lan
Guardar Imagen en PostgreSQL
Programación Visual Basic
9ttnix 6 5,431 Último mensaje 27 Septiembre 2016, 00:12 am
por 9ttnix
abrir y guardar imagen en c
Programación C/C++
yoelmend 1 2,484 Último mensaje 9 Julio 2017, 12:30 pm
por ivancea96
Error al guardar imagen PGM P2
Programación C/C++
AdrianGL13 4 2,766 Último mensaje 31 Mayo 2018, 22:41 pm
por srWhiteSkull
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines