Jump to content


Photo

Class Thumbs()


  • Faça o login para participar
7 replies to this topic

#1 Squall Robert

Squall Robert

    Mr. Squall - Mais Carne do que Osso (hihi)

  • Usuários
  • 507 posts
  • Sexo:Masculino
  • Localidade:Curitiba
  • Interesses:Php ... Php...Php

Posted 02/01/2009, 20:38

Olá pessoal... estava fazendo um sistema e precisei gerar umas imagens, ai acabei gerando uma classe ai que pode ajudar a galera

vou postar aqui pra quem precisar blz....

classe.php
<?php

/**
 * @author squall
 * @copyright 2009
 */

class Thumbs
{
	//variaveis necessárias para gerar thumbs
	public $caminho;
	public $nome;
	public $tamanho;
	public $arquivo;
	public $ext;
	public $tipo;
	public $ImagemGerada;
	
	public function Thumbs()
	{
		// definindo valores padrão de variaveis
		$this->tipo = 1;
		$this->nome = date('YmdHis');	
	}
	//preparando imagem 
	public function Prepare()
	{
		// verifica imagem se existe
		if(file_exists($this->arquivo))
		{
			// gerando nome da nova imagem
			$this->NomeImagem();
						
			if(!file_exists($this->ImagemGerada))
			{
				// pegando tamanho da imagem
				$img_tamanho = @getimagesize($this->arquivo);
				// comparando tamanho solicitado com tamanho atual da imagem
				if($img_tamanho[0] > $this->tamanho)
				{
					// pegando extensão da imagem
					$this->ext = substr($this->arquivo,-3);
					// verificando se o caminho e existente/ se não cria diretório
					$this->CriarDir();
					
					// gerando imagem
					return $NovaImagem = $this->Gerar();
								
				}
				else
				{
					// se o tamanho e menor que o solicitado , retorna imagem
					return $this->arquivo;			
				}
			}
			else
				return $this->ImagemGerada; // retorno da imagem existente																																
		}
		else
			return false; //retorna false se o arquivo nao for encontrado
	}
	
	// Gerador de Thumbs
	public function Gerar()
	{
		// se extesão for jpg 
		if($this->ext == "jpg")
		{
			$imagem_orig = @imagecreatefromjpeg($this->arquivo);
		}
		elseif($this->ext=="png")
		{
			$imagem_orig = @ImageCreateFromPNG($this->arquivo);
		}
		elseif($this->ext=="gif")
		{
			$imagem_orig = @ImageCreateFromGIF($this->arquivo);
		}
		
				
		// pegando tamanhos da imagem
		$pontoX = @ImagesX($imagem_orig);
		$pontoY = @ImagesY($imagem_orig);
		// gerando altura proporcional ao tamanho solicitado
		$altura=($this->tamanho * $pontoY)/$pontoX;
		
		//gerando imagem final
		$imagem_final=@ImageCreateTrueColor($this->tamanho,$altura);
		@ImageCopyResampled($imagem_final,$imagem_orig, 0, 0, 0, 0,$this->tamanho,$altura,$pontoX,$pontoY);
		
		$imagem_ext=@substr($this->arquivo,-3);
		
		// gerando arquivo
		if($this->ext=="jpg")
			@imagejpeg($imagem_final,$this->ImagemGerada,80);
		if($this->ext == "png")
			@imagepng($imagem_final,$this->ImagemGerada);
		if($this->ext == "gif")
			@imagegif($imagem_final,$this->ImagemGerada);
		
		// destruindo informações desnecessárias
		@imageDestroy($imagem_orig);
		@imageDestroy($imagem_final);
		
		//retornando caminho da nova imagem
		return $imagem_gerada;	
	}
	public function CriarDir()
	{
		if(!is_dir($this->caminho))
		{
			mkdir($this->caminho,0777);		
		}				
	}
	public function NomeImagem()
	{
		//pegando nome original da imagem
		$imagemLimpando = @explode("/",$this->arquivo);
		$imagemNome = $imagemLimpando[(count($imagemLimpando) - 1)];
		
		// se o tipo for  igual a 1 ele usa o nome original da imagem
		// se não ele usa o timestamp para gerar um nome unico
		if($this->tipo == 1) $imagem_gerada=$this->caminho . $imagemNome;
		else $imagem_gerada = $this->caminho . $this->nome . "." .  $this->ext;
		
		$this->ImagemGerada = $imagem_gerada;
	}
}

?>


como usar a classe

<?php

/**
 * @author squall
 * @copyright 2009
 */

include("Thumbs.php");

$Gerar = new Thumbs();

$Gerar->caminho = "dddddde/";
$Gerar->tamanho = 250;
$Gerar->arquivo = "dir/sss.jpg";
$imagem = $Gerar->Prepare();

?>
<img src="<?=$imagem;?>" />

tai .. falows...

Edição feita por: Squall Robert, 03/01/2009, 07:17.

<?php

$squall = new Squall();

$squall->Ajudando("você");

$resultado = $squall->solucao();  ?>

#2 Dudu

Dudu

    Viva la vida

  • Usuários
  • 1437 posts
  • Sexo:Masculino
  • Localidade:Uberlândia - MG
  • Interesses:PHP

Posted 03/01/2009, 21:26

Tópico movido para Banco de funções.
Peço que edite seu post de acordo com o padrão da Sessão.

PS: Tomei a liberdade de alterar o título, pois estava escrito thunbs. ^_^

-----------------
Edit

Vou trancar o tópico, até que o dono venha e edite de acordo com as regras da sessão.
Quando mudar, me manda MP que eu abro o tópico.


Até mais

Fórum WMO - Equipe de Desenvolvimento / Banco de Dados - Moderador


Twitter: HostCheap


#3 Squall Robert

Squall Robert

    Mr. Squall - Mais Carne do que Osso (hihi)

  • Usuários
  • 507 posts
  • Sexo:Masculino
  • Localidade:Curitiba
  • Interesses:Php ... Php...Php

Posted 09/01/2009, 08:44

ai .. galera,,,,

qualquer duvida sobre a função so postar...

assim que possivel vou vendo ..

ok
<?php

$squall = new Squall();

$squall->Ajudando("você");

$resultado = $squall->solucao();  ?>

#4 Silvio Martins

Silvio Martins

    Novato no fórum

  • Usuários
  • 1 posts
  • Sexo:Masculino
  • Localidade:Juiz de Fora, MG

Posted 25/07/2010, 13:03

Boa tarde,

Gostaria que me ajudasse, pois estou usando sessão para controlar o acesso as paginas, só que nas paginas que exibem fotos com referencia do banco de dados, nestas paginas as sessões estão se perdendo, sendo assim quando eu tento navegar em outra pagina, não existe mais a sessão, assim sou redirecionado para a página inicial. Sei que o problema é as fotos pois quando eu tiro as fotos as sessões funcionam perfeitamente.

Att.

Silvio Martins

#5 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 15/10/2017, 15:41

Zithromax Otc levitra professional Mantadix Vente En Ligne Kamagra Generic Canada Achat Cialis Avis
Propecia Heart Disease Amoxicillin 500 Clav K 125mg Treats Amoxicillin Dairy Products viagra online Prix Cialis One Day

#6 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 16/10/2017, 19:00

Can Cephalexin Affect Blood Sugar cialis Tadalis Sx Soft Canada Online Pharmacy Kamagra Prescrizione Usa Generico Cialis Forum
Baclofene Dose Maximale Keflex Is Not Very Strong cheap cialis Is A Prescription Needed For Caverta Buy Pfizer Viagra Pills Australia Acquisto Sicuro Viagra Online
Tedarise 20 Online Amoxicillin Liver Damage Propecia Cerebro viagra Buy Alli In Mexico
accutane buy online reviews buy vardenafil online cheap Para Que Sirve Levitra 10 Mg
Progesterone No Prescription Needed Combivir Priligy Dapoxetine In The U.S generic viagra Does Amoxicillin Help A Boil
Cialis 40 Mg Dosage Levitra 10 Mg Prospecto cialis price Buy Zithromax Usa Dexamethasone Mixed With Amoxicillin Kamagra Online Di Grenoble
Viagra Sildenafil Wirkung Viagra For Sale In Usa viagra Cialais Vente Cialis Generique Andorre
Cialis Generic Chepest Po Box Delivery Is Trazodone Available In Australia Is Penicillin The Same As Amoxicillin levitra online Watery Bloody Stools Amoxicillin
Priligy Rezeptfrei Kaufen viagra Cephalexin For Dogs
Pfizer Viagra Discount Card Cialis 20 Vendita Misoprostol En Ligne Canada mail order levitra Ordonnance Cialis Generic Company Propecia
Anything Otc Like Viagra Or Cialis Amoxicilina 650mg Discount In Us With Free Shipping generic levitra on line Levitra 10 Mg Generico Kamagra Bestellen Und Kaufen Viagra Frei Kaufen
Free Levitra Samples cialis price Cialis 10mg Filmtabletten
Pharmacia Online Usa Priligy Information Produit Kamagra Per Nachnahme viagra Potenzmittel Cialis Billig
Prix Cialis One Day Viagra Bereber Viagra Cheap Usa levitra 20mg best price Finasteride Delivered
Il Cialis Cura Compra Levitra Clomid Tablets Buy Without Prescription buy viagra Cialis E Hiv Amoxicillin Vs Ciprofloxacin Medicamentos Viagra
Thyrox 200 Order Online No Prescription viagra Medrol Over The Counter Options
Cheapest Doxycycline Uk Achat Amoxicillin Pharmacie Distribuer Produits Acheter Viagra Marseille viagra cialis Propecia Hair Loss Symptoms Viagra 24 Ore
Is Keflex Sulfur Drug generic viagra Cialis 5 Effets Secondaires Celecoxib 200 Mg Price Keflex And Birth Control
Cash On Delivery Levaquin Buy Amoxicillin 875 Mg No Prescription Buy Propecia Online generic viagra Pilule Viagra Moin Chere
Cialis Per Disfunzione Erettile buy viagra Rx4 Pharmacy Levitra Scheda Tecnica

#7 aapedlok

aapedlok

    24 Horas

  • Usuários
  • 450 posts
  • Sexo:Masculino
  • Localidade:Alpharetta

Posted 17/10/2017, 01:33

Discounts! best product design 2017 progect11.jpg Products which fall under this return policy can be returned domestically, as long as they are unused and in the original packaging. No questions asked! If a product that falls under this guarantee is found to be counterfeit, you will get a full refund (shipping costs included). buy.png READ MORE Free Shipping Brand for xiaomi redmi 3 redmi 3S 3pro tempered glass screen protector Film redmi 3 s redmi 3 Pro Glass 0.33mm ( 1.76 $)Black Cubic Zirconia Sterling Silver Ring ( 135.00 $)New men fleece thermal outdoor sport underwear motorcycle skiing winter warm base layers tight long johns tops & pants set ( 37.60 $)Ideafly Mars - 350 RC Quadcopter-354.87 $SOCOOLE W08 Swimming Smartwatch Phone-62.60 $Chic bohemian rhombus pattern fringed edge winter scarf for women ( 8.99 $)Brazilian virgin hair with closure queen hair product brazilian hair weave bundles with closure brazilian body wave with closure ( 62.30 $)«V konspirativnie goda»Double Side Simulated Pearl Balls Stud Earrings For Women Fashion Candy Colors Female Pusety Earring Girls Ear Jewelry Brincos ( 1.59 $)7a malaysian virgin hair malaysian body wave 4bundles rosa hair products malaysian body wave virgin hair 100% human hair soft ( 43.34 $)Crystal From Swarovski Jewelry Bohemia Brincos round stone stud Ear Rhodium Plated Long Drop Dangle Earrings For Woman Gift ( 2.00 $)Iggy honey mustard leather clutch ( 163.26 $) Diane Von FurstenbergCubot CHEETAH 2 4G Phablet-171.69 $Geo Classic - Geo Print Belt ( 75.00 $)Big mouth toilet stickers wall decorations 342 diy vinyl adesivos de paredes home decal mual art ( 1.71 $) 3.jpg
Discounts! best cosmetic products 2017

progect11.jpg
Products which fall under this return policy can be returned domestically, as long as they are unused and in the original packaging. No questions asked!
If a product that falls under this guarantee is found to be counterfeit, you will get a full refund (shipping costs included).

buy.png

READ MORE
Famous Brand Sexy High Quality Women Print Bra set Silk Lace Flower Push up Big size ( 13.83 $)
Retail 2016 good fishing lures minnow,quality professional baits 8.8cm7.2g,bearking hot model crankbaits penceil bait popper ( 5.00 $)
New design fashion tattoo tattoo of gold and silver necklace bracelet model products waterproof temporary tattoo Flash tattoos ( 0.88 $)
Original xiaomi mi power bank 2 10000mah external battery portable mobile backup bank mi charger for ( 24.99 $)
Solid Silk Scarf ( 49.00 $)
BLUBOO Dual Android 6.0 5.5 inch FHD IPS Screen 4G Phablet MTK6737 Quad Core 1.5GHz 2GB RAM 16GB ROM 2.0MP + 13.0MP Dual Back Cameras GPS Fingerprint Scanner$
Ulefone U007 3G Smartphone-54.99 $
X-bag medium 3-in-one tote ( 66.65 $) Bric s
Mr Bean Teddy Bear Figure 12cm 3D Model Plush Toy Animals Stuffed Doll Sucker Pendant ( $1.12 )
Partol h4 h7 h11 9005 9006 h13 car led headlight bulbs 80w 9600lm cree xhp50 chips ( 37.99 $)
Hot 2017 Fashion Women Belts Luxury PU Leather Pin Buckle Belt Women Casual All-Match Embossed Popular Ladies Belt 110-115CM ( 9.78 $)
Type-C USB 3.1 OTG Adapter ( $2.19 )
Xiaomi Mi5s Plus 4G Phablet-467.04 $
50pcslot Hot Sale Special Professional 15 COLOR Concealer Facial Care Camouflage Makeup Palette ( 82.00 $)
AMD Athlon 64 X2 4800+ CPU ( $3.59 )


233.jpg
Discounts! best product page design

progect11.jpg
Products which fall under this return policy can be returned domestically, as long as they are unused and in the original packaging. No questions asked!
If a product that falls under this guarantee is found to be counterfeit, you will get a full refund (shipping costs included).

buy.png

READ MORE
Evet kinky curly brazilian human hair 7a unprocessed virgin hair weaves set not full head hair extensions 4pcs 4x8 ( 27.72 $)
Plastic rolling tube squeezer useful toothpaste easy dispenser bathroom holder free shipping ( 0.68 $)
Jet set travel chain top zip multifunction tote ( 243.40 $) Michael Kors
2015 new arrive women winter sweater dresses slim turtleneck long knitted dress sexy bodycon robe dress d019 ( 39.98 $)
2016 new wholesale vintage design crystal earring fashion women statement stud Earrings for women fashion earring ( 2.87 $)
Life papyrus micro suede 21 carry on spinner ( 291.33 $) Bric s
Zolotaya korona (Igra prestolov)
New 2016 summer style sexy skirt for girl lady korean short skater fashion female mini skirt ( 7.98 $)
Free screen protector xiaomi mi 5 case matte pc back cover case for xiaomi mi5 cases ( 3.88 $)
LiDi RC L6F RC126 5.8GHz FPV HD 2 Mega Pixel CAM 2.4G 4CH 6 Axis Gyro Hexacopter 3D Rollover-89.12 $
Newest car camera car dvr blue review mirror digital video recorder auto registrator camcorder full hd 1080p camera car dvrs ( 59.98 $)
Free shipping led Illuminated Furniture,Bubble,waterproof led table,led coffee table rechargeable for Bars,party,Christmas ( 229.99 $)
LY MAX 8 4G Phablet-84.99 $
Gibbons, Sedrik
AOTDDOR EDC Pocket Size Key Clip Oxide Aluminum Made Backpack Accessory 2.39$


226.jpg

#8 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 17/10/2017, 19:30

Healthymale viagra Kamagra Cheap Uk
Best Over The Counter Viagra Substitute extra super levitra Does Cephalexin Help With Cellulites How To Buy Viagra Prescription
Comprar Viagra Cialis Priligy Italy Buy Zithromax By The Pill viagra Skelaxin Citalopram Without Perscription Kamagra Oral Jelly Vol.3
Cialis E Ipotiroidismo buy viagra Viagra Pas Cher Au Canada Purchasing Stendra From Canada




0 user(s) are reading this topic

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq