Jump to content


rAFiLXs's Content

There have been 2 items by rAFiLXs (Search limited from 29/03/2023)


Ordernar por                Order  

#850950 Gerador De Thumbnails

Posted by rAFiLXs on 26/05/2007, 11:42 in Artigos, Dicas e Tutoriais de PHP

Depois de testar dezenas de geradores de thumbnails q procurei pela net, nao enncontrei nenhum que mesmo definindo a qualidade do JPG como 100, chegasse a uma qualidade realmente BOA.

Até que achei esse codigo no site da biblioteca GD, testem ai, o resultado é equivalente ao photoshop!

<?php

	$i = new imagethumbnail();
	$i->open("teste.jpg"); // coloque aqui o nome do arquivo original
	$i->setX(100);
	
	header("Content-type: image/jpeg;");
	$i->imagejpeg();

	class imagethumbnail {
	
		var $filename;
		var $x;
		var $y;
		var $image;
		var $thumbnail;

		function imagethumbnail() {

		}
		
		function open($filename) {

			$this->filename = $filename;
			$imageinfo = array();
			$imageinfo = getimagesize($this->filename,$imageinfo);
			
			$this->old_x = $imageinfo[0];
			$this->old_y = $imageinfo[1];
						
			switch ($imageinfo[2]) {
				case "1": $this->image = imagecreatefromgif($this->filename); break;
				case "2": $this->image = imagecreatefromjpeg($this->filename); break;
				case "3": $this->image = imagecreatefrompng($this->filename); break;
			}
			
		}

		function setX($x="") {
			if (isset($x)) { $this->x = $x; }
			return $this->x;
		}

		function setY($y="") {
			if (isset($y)) { $this->y = $y; }
			return $this->y;
		}

		function generate() {

			if ($this->x > 0 and $this->y > 0) {
				$new_x = $this->x;
				$new_y = $this->y;
			} elseif ($this->x > 0 and $this->x != "") {
				$new_x = $this->x;
				$new_y = ($this->x/$this->old_x)*$this->old_y;
			} else {
				$new_x = ($this->y/$this->old_y)*$this->old_x;
				$new_y = $this->y;
			}

			$this->thumbnail = imagecreatetruecolor($new_x,$new_y);
			$white = imagecolorallocate($this->thumbnail,255,255,255);
			imagefill($this->thumbnail,0,0,$white);

			imagecopyresampled ( $this->thumbnail, $this->image, 0, 0, 0, 0, $new_x, $new_y, $this->old_x, $this->old_y);

		}

		function imagegif($filename="") {
			if (!isset($this->thumbnail)) { $this->generate(); }
			imagetruecolortopalette($this->thumbnail,0,256);
			if ($filename=="") {
				imagegif($this->thumbnail);
			} else {
				imagegif($this->thumbnail,$filename);
			}
		}

		function imagejpeg($filename="",$quality=100) {
			if (!isset($this->thumbnail)) { $this->generate(); }
			imagejpeg($this->thumbnail,$filename,$quality);
		}

		function imagepng($filename="") {
			if (!isset($this->thumbnail)) { $this->generate(); }
			if ($filename=="") {
				imagepng($this->thumbnail);
			} else {
				imagepng($this->thumbnail,$filename);
			}
		}

	}
	
?>



#814726 Flash Em Tela Inteira

Posted by rAFiLXs on 10/01/2007, 15:47 in Adobe Flash e ActionScript

Estou montando um site em flash em tela inteira, alguem sabe como manter um objeto fixo no fim da página?

Pra quem nao entendeu, de uma olhada no fim dessa página...
http://www.rafaeleltz.com.br/

Não importa a resolução da tela aquela barra sempre fika grudada no fim

Obrigado




IPB Skin By Virteq