Está en la página 1de 1

<html>

<head>
<title>ejemplo de resized</title>
</head>
<boody>
<h1 align='center'>Ejemplo de redimensionamiento</h1>
<h3 align='center'>Imagen Original</h3>
<center>
<img src='calle.jpg' alt='calle.jpg' border='1' width='100'/>
</center>
<table border='3' align ='center'>
<tr>
<td align='center'>imagen al 5%</td>
<td align='center'>imagen al 10%</td>
<td align='center'>imagen al 20%</td>
</tr>
<tr>
<td>
<img src="redimensiona.php?imagen=calle.jpg&factor=0.05" />
</td>
<td>
<img src="redimensiona.php?imagen=calle.jpg&factor=0.10" />
</td>
<td>
<img src="redimensiona.php?imagen=calle.jpg&factor=0.20" />
</td>
</tr>
</table>
</boody>
</html>

<?php
//<!-- Cap12/redimensiona.php -->
//recupero los parametros
$imagen = $_get['imagen'];
$factor = $_get['factor'];
//content-type para el navegador
heder('content-type: image/jpg');
//se obtiene las nuevas dimensiones
$tamanio = getimagesize($imagen);
$nuevoancho = $tamanio[0]*$factor;
$nuevoalto = $tamanio[1]*factor;
//cargar la imagen
$nueva = imagecreate($nuevoancho,$nuevoalto);
$origen = imagecreatefromjpeg($imagen);
//redimensionar
imagecopyresized($nueva,$origen,0,0,0,0,$nuevoancho,$nuevoalto,$tamanio[0],taman
io[1];
//mostrar la nueva imagen
imagejpeg($nueva);
?>

También podría gustarte