note 37803 added to ref.image

From: Date: Thu, 27 Nov 2003 19:30:54 +0000
Subject: note 37803 added to ref.image
Groups: php.notes 
Request: Send a blank email to php-notes+get-61043@lists.php.net to get a copy of this message
# ------------------------------------------------------------- # # FUNÇÃO 'THUMB' GERA UM THUMBS DE UMA IMAGEM DO FORMULÁRIO # # FOR GD >= 2.0 # # SCRIPT BY RHALLADO # # $arquivo_origem = Arquivo de origem com diretório # # $arquivo_destino = Arquivo de Destino com diretório # # max_w = Tamanho maximo Horizontal da nova imagem # # max_h = Tamanho maximo Vertical da nova imagem # # qualidade = Qualidade da nova imagem # # ------------------------------------------------------------- # function thumb($arquivo_origem, $arquivo_destino, $max_w, $max_h, $qualidade) { if (!is_uploaded_file($arquivo_origem) ) { $error[] = 'O arquivo de origem: "' . $arquivo_origem . '" é inválido!'; } if ( $arquivo_destino == '' ) { $error[] = 'O arquivo de destino inválido!'; } if ( $max_w < '1' ) { $error[] = 'Tamanho horinzontal inválido!'; } if ( $max_h < '1' ) { $error[] = 'Tamanho vertical inválido!'; } if ( $qualidade < '1' ) { $error[] = 'Qualidade de compactação inválida!'; } if ( $error == '' ) { copy($arquivo_origem,$arquivo_destino); $pic = @imagecreatefromjpeg($arquivo_destino); $real_width = imagesx($pic); $real_height = imagesy($pic); $scale = min($max_w/$real_width, $max_h/$real_height); if($scale <1){ $max_w = floor($scale*$real_width); $max_h = floor($scale*$real_height); } $thumb = @imagecreatetruecolor ($max_w, $max_h); ImageCopyResampled($thumb, $pic, 0, 0, 0, 0, $max_w, $max_h, $real_width, $real_height); Imagejpeg($thumb,$arquivo_destino,$qualidade); } for ($i = 0; $i < count($error); $i++){ echo "$error[$i]<br>"; } } if ( $file != '' ) { thumb($_FILES['file']['tmp_name'],'deu.jpg', '400', '300','70'); } ---- Manual Page -- http://www.php.net/manual/en/ref.image.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37803 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37803&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37803&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61043) next »