Ir para conteúdo
Fórum Script Brasil

dougty

Membros
  • Total de itens

    2
  • Registro em

  • Última visita

Sobre dougty

dougty's Achievements

0

Reputação

  1. Muito obrigado pela ajuda... Eu mesmo acabei resolvendo, segue função criada: <?php function reduz_imagem($nome_img, $wid, $hei) { $im = imagecreatefromjpeg($nome_img); $w = imagesx($im); $h = imagesy($im); $w1 = $w / $wid; if ($hei == 0) { $h1 = $w1; $hei = $h / $w1; } else { $h1 = $h / $hei; } $min = min($w1,$h1); $xt = $min * $wid; $x1 = ($w - $xt) / 2; $x2 = $w - $x1; $yt = $min * $hei; $y1 = ($h - $yt) / 2; $y2 = $h - $y1; $x1 = (int) $x1; $x2 = (int) $x2; $y1 = (int) $y1; $y2 = (int) $y2; $img = NULL; $img = imagecreatetruecolor($wid, $hei); imagecolorallocate($img,255,255,255); $c = imagecolorallocate($img,255,255,255); $c1 = imagecolorallocate($img,0,0,0); for ($i=0;$i<=$hei;$i++) { imageline($img,0,$i,$wid,$i,$c); } imagecopyresampled($img,$im,0,0,$x1,$y1,$wid,$hei,$x2-$x1,$y2-$y1); imagejpeg($img, $nome_img, 100); } ?>
  2. O código é ótimo mais gostaria que ao invés de mostrar a thumbs (ex. thumbs.php?w=100&h=100&imagem=teste.jpg) gostaria que ele salva-se a imagem thumb no diretório. Já tentei de tudo não consegui alguém, me ajuda =] <?php header("Content-type: image/jpeg"); $im = imagecreatefromjpeg($_GET['imagem']); // Cria uma nova imagem a partir de um arquivo ou URL $wid = (int)$_GET["w"]; $hei = (int)$_GET["h"]; $w = imagesx($im); $h = imagesy($im); $w1 = $w / $wid; if ($hei == 0) { $h1 = $w1; $hei = $h / $w1; } else { $h1 = $h / $hei; } // echo "$h1 - $w1"; $min = min($w1,$h1); $xt = $min * $wid; $x1 = ($w - $xt) / 2; $x2 = $w - $x1; $yt = $min * $hei; $y1 = ($h - $yt) / 2; $y2 = $h - $y1; $x1 = (int) $x1; $x2 = (int) $x2; $y1 = (int) $y1; $y2 = (int) $y2; $img = NULL; $img = imagecreatetruecolor($wid, $hei); //$background = imagecolorallocate($img, 50, 50, 50); imagecolorallocate($img,255,255,255); $c = imagecolorallocate($img,255,255,255); $c1 = imagecolorallocate($img,0,0,0); for ($i=0;$i<=$hei;$i++) { imageline($img,0,$i,$wid,$i,$c); } imagecopyresampled($img,$im,0,0,$x1,$y1,$wid,$hei,$x2-$x1,$y2-$y1); imagejpeg($img); ?>
×
×
  • Criar Novo...