criar thumbnail permanente, não temporário
ESSE script q eu utilizo cria um thumbnail apenas temporário.Como faço pra criar um permanente no ato do upload.
resize_image.php
CODE
<?php
$image = $HTTP_GET_VARS['imagem'];
// LARGURA E ALTURA PADRÃO DO THUMB
if (!$max_width)
$max_width = 155;
if (!$max_height)
$max_height = 116;
// PEGA A LARGURA E ALTURA DA IMAGEM ORIGINAL
$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];
z
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if ( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
// CRIA NOVA IMAGEM
$src = ImageCreateFromJpeg($image);
$dst = ImageCreateTrueColor($tn_width,$tn_height);
ImageCopyResampled($dst, $src, 0, 0, 0, 0,
$tn_width,$tn_height,$width,$height);
header('Content-type: image/jpeg');
ImageJpeg($dst);
ImageDestroy($src);
ImageDestroy($dst);
?>
upload.php
CODE
//UPLOAD DAS IMAGENS
<?
if ( (isset($HTTP_POST_FILES['imagem']['name']) &&
is_uploaded_file($HTTP_POST_FILES['imagem']['tmp_name'])))
{
if (!isset($imovel))
$imovel = mysql_insert_id();
//RETORNA PARTE DO NOME DO ARQUIVO DO CAMINHO Q FOI FEITO PARA PEGAR A IMAGEM
$type = basename($HTTP_POST_FILES['imagem']['type']);
//MOVE O ARQUIVO UPLOADED PARA UM CAMINHO ESPECÍFICO NO CASO PARA PASTA PICTURES
switch ($type) {
case 'jpeg':
case 'pjpeg': $filename = "pictures/$imovel.jpg";
move_uploaded_file($HTTP_POST_FILES['imagem']['tmp_name'],
$filename);
$sql = "update imovel
set imagem = '$filename'
where id = $imovel";
$result = mysql_query($sql, $conn);
break;
default: print 'O formato da figura é inválido: '.
$HTTP_POST_FILES['imagem']['type'];
}
}
?>
?>
AGRADEÇO
ABRAÇO A TODOS
Discussão (3)
Carregando comentários...