Foros del Web » Programando para Internet » PHP »

Guardar en jpg

Estas en el tema de Guardar en jpg en el foro de PHP en Foros del Web. Tengo el sigueinte codigo, por que cuando le doy a guardar imagen como.. me sale en tipo : PHP Script como consigo que me salga ...
  #1 (permalink)  
Antiguo 03/10/2011, 08:46
 
Fecha de Ingreso: septiembre-2011
Mensajes: 26
Antigüedad: 12 años, 6 meses
Puntos: 0
Guardar en jpg

Tengo el sigueinte codigo, por que cuando le doy a guardar imagen como.. me sale en tipo : PHP Script como consigo que me salga en .jpg pueden decir

Crea la imagen :
Código PHP:
<?php

/* JPEGCam Test Script */
/* Receives JPEG webcam submission and saves to local file. */
/* Make sure your directory has permission to write files as your web server user! */

$filename date('YmdHis') . '.jpg';
$result file_put_contents$filenamefile_get_contents('php://input') );
if (!
$result) {
    print 
"ERROR: Failed to write data to $filename, check permissions\n";
    exit();
}

$url 'http://' $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']) . '/imagen.php?src=' $filename;
print 
"$url\n";

?>
Crea la marca de agua :
Código PHP:
<?php
$src 
$_GET['src'];
$maxsize $_GET['maxsize'];

if (
$maxsize == '') {
$maxsize 75;
}

// el archivo o imagen
$filename $src;

// Asignar el ancho y alto maximos
$width 640;
$height 480;

// mandando las cabeceras correspondientes
header('Content-type: image/jpeg');

// obteniendo las dimensiones actuales
list($width_orig$height_orig) = getimagesize($filename);

if (
$width && ($width_orig $height_orig)) {
$width = ($height $height_orig) * $width_orig;
} else {
$height = ($width $width_orig) * $height_orig;
}

// Cambiando el tamano de la imagen o resample
$image_p imagecreatetruecolor($width$height);
$image imagecreatefromjpeg($filename);
imagecopyresampled($image_p$image0000$width$height$width_orig$height_orig);

// Marca de Agua o Watermark
$watermark imagecreatefrompng('img/watermark.png');
$watermark_width imagesx($watermark);
$watermark_height imagesy($watermark);
$image imagecreatetruecolor($watermark_width$watermark_height);
$dest_x $width $watermark_width 5;
$dest_y $height $watermark_height 5;
imagecopymerge($image_p$watermark$dest_x$dest_y00$watermark_width$watermark_height30);

// Salida
imagejpeg($image_p);
imagedestroy($image);
imagedestroy($image_p);
imagedestroy($watermark);
?>
Se muestra en la Web :
Código PHP:
<img src="' + image_url + '" alt="img" /> 
  #2 (permalink)  
Antiguo 03/10/2011, 10:05
Avatar de mcun  
Fecha de Ingreso: octubre-2010
Ubicación: tras la pantalla
Mensajes: 466
Antigüedad: 13 años, 6 meses
Puntos: 55
Respuesta: Guardar en jpg

no entendí
  #3 (permalink)  
Antiguo 03/10/2011, 10:16
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Guardar en jpg

En tus cabeceras le tienes que indicar también el nombre del archivo:
Código PHP:
Ver original
  1. header ('Content-disposition: inline; filename="myfile.jpg"');

Saludos.
  #4 (permalink)  
Antiguo 03/10/2011, 12:17
 
Fecha de Ingreso: septiembre-2011
Mensajes: 26
Antigüedad: 12 años, 6 meses
Puntos: 0
Respuesta: Guardar en jpg

ya esta Gracias GatorV

Etiquetas: jpg
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 21:38.