Se quiser pode testar esse controller que eu fiz a um tempo atrás, gera miniatura de imagens grandes sem problemas.
chamo dessa forma: <img src="http://localhost/site/miniatura/arquivo.jpg"> <?php class Miniatura extends MY_Controller { function Miniatura() { parent::MY_Controller(); } function index($arquivo="") { $dir = attach_path(); $scalevalue = "200"; $scalemode = 'auto'; $caminho_completo = $dir.$arquivo; //Verifica se é uma imagem e qual é a extensão $img = array('png','gif','jpg','PNG','GIF','JPG'); $ext = explode(".",$arquivo); $ext = $ext[1]; // Pega as dimensões da imagem list($width, $height) = getimagesize($caminho_completo); $scale = min($scalevalue/$width, $scalevalue/$height); if ($scale < 1) { $newwidth = floor($scale * $width); $newheight = floor($scale * $height); } $image_p = imagecreatetruecolor($newwidth, $newheight); if($ext == 'JPG' OR $ext == 'jpg') { header('Content-type: image/jpeg'); $image = imagecreatefromjpeg($caminho_completo); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); } if($ext == 'png' OR $ext == 'PNG') { header('Content-type: image/png'); $image = imagecreatefrompng($caminho_completo); imagealphablending($image_p, false); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagesavealpha($image_p,true); } if($ext == 'gif' OR $ext == 'GIF') { header('Content-type: image/gif'); $image = imagecreatefromgif($caminho_completo); imagealphablending($image_p, false); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagesavealpha($image_p,true); } header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); ob_clean(); flush(); if($ext == 'JPG' OR $ext == 'jpg') imagejpeg($image_p, null, 100); if($ext == 'png' OR $ext == 'PNG') imagepng($image_p); if($ext == 'gif' OR $ext == 'GIF') imagegif($image_p); imagedestroy($image_p); } } ?> 2010/12/8 John <[email protected]> > Acho mais viável criar o arquivo, mais seguro. > > Sempre que vou fazer dinamização e até mesmo imagens com marca d'agua, gero > os arquivos. > > Nada que um limpador de cache e temp não resolva de semana em semana... > > Acredito que o tempo de processamento da imagem seja menor, e não envia ele > para o navegador. > > -- > John > Sent with Sparrow <http://www.sparrowmailapp.com> > > On Wednesday, December 8, 2010 at 1:10 AM, Junior Messias wrote: > > Assim, tenho uma imagem e dependendo onde vou usá-la utilizo tamanho > diferente... por isso o resize... o arquivo existe. > > Eu não preciso do arquivo temporário, por isso quero gerar no momento que > mostrar, somente. > > Criar um temp, criando o arquivo no servidor? é o que faço se tiro o > dynamic_image... crio uma imagem com o nome sendo o ano '2010.jpg', assim a > que está no momento é o arquivo... queria evitar a escrita de arquivo.... > > Tens utilizado algo assim John? > > ------------------------------------------------------- > Israel Messias Junior > e-mail: [email protected] > > > > Em 8 de dezembro de 2010 01:01, John <[email protected]> escreveu: > > Cara, acho que tem um pequeno erro ai... > > o resize funciona com arquivos fisicos... não acredito que de para fazer > com geração dinamica... a imagem tem q existir, ou estou errado? > > e se precisa dimensionar, e precisa do arquivo temporario, pq não cria um > temp padrão para tudo que for gerar, não ocupa espaço... e esta sempre > gerando dinamico, sem problemas... > > O código esta ok... > > -- > John > Sent with Sparrow <http://www.sparrowmailapp.com> > > On Tuesday, December 7, 2010 at 9:56 PM, Junior Messias wrote: > > Então... estão usando algum lugar para colocar códigos-fonte?? > > Vou postar aí embaixo.. > > function img_dinamica($img_entrada, $maximo = 200) > { > $img['image_library'] = 'gd2'; > $img['new_image'] = $this->dir.date('Y').'.jpg'; > $img['source_image'] = $img_entrada; > $img['dynamic_output'] = TRUE; > $img['maintain_ratio'] = TRUE; > $img_entrada_arr = getimagesize($img_entrada); > $largura = $img_entrada_arr[0]; > $altura = $img_entrada_arr[1]; > > if($largura >= $altura) > { > $img['width'] = $maximo; > $img['height'] = round(($img['width'] * $largura) / $altura); > } > else > { > $img['height'] = $maximo; > $img['width'] = round(($img['height'] * $altura) / $largura); > } > header('Content-type: '.$imgd->mimetype.'; name='.$imgd->arquivo); > $this->image_lib->initialize($img); > $this->image_lib->resize(); > //return site_url($img['new_image']); > } > > Bem, pelo que 'entendi' ele deveria retornar a imagem, se eu comentar a > linha > > $img['dynamic_output'] = TRUE; > > e habilitar o return.. ele retorna a imagem criada... mas não quero criar a > imagem.. que só descarregue no navegar e só... > > Quando utilizo return, uso uma view q executa isso ai e retorna so a url... > funciona corretamente... > > ------------------------------------------------------- > Israel Messias Junior > e-mail: [email protected] > > > > Em 7 de dezembro de 2010 21:20, John <[email protected]> escreveu: > > Tu poderia postar o código que ta usando ou o link para darmos uma > olhada? > > Já verificou permissões na pasta temporaria e tal? > > as bibliotecas do php... versão do php > > > -- > John > Sent with Sparrow <http://www.sparrowmailapp.com> > > On Tuesday, December 7, 2010 at 9:07 PM, Junior Messias wrote: > > Se acesso direto a imagem ou a página não exibe nada... =/ > ------------------------------------------------------- > Israel Messias Junior > e-mail: [email protected] > > > > Em 7 de dezembro de 2010 20:40, John <[email protected]> escreveu: > > Se voce acessar direto a página, ela exibe o hexa? > > -- > John > Sent with Sparrow <http://www.sparrowmailapp.com> > > On Tuesday, December 7, 2010 at 8:26 PM, Junior Messias wrote: > > Marcel, já tentei modificar o header... a lib mooo image tb faz isso qdo > utilizada... > > Sim John, é isto mesmo... mas no código fonte fica o hexadecimal da > imagem... > > ------------------------------------------------------- > Israel Messias Junior > e-mail: [email protected] > > > > Em 7 de dezembro de 2010 13:38, Marcel Araujo <[email protected]>escreveu: > > Já tentasse modificar o header para que o browser indentifique como uma > imagem? > > -- > Abraços...... > > Marcel Araujo > System Analyst > Administrator at CodeIgniter.com.br > Developer jQuery/ExtJS/PHP/CodeIgniter/Zend > Linux User #490101 > http://br.linkedin.com/in/marcelaraujo > http://www.twitter.com/marcelaraujo > http://www.marcelaraujo.com.br > > _______________________________________________ > [email protected] > http://www.codeigniter.com.br > http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br > > --------------------------- > Oportunidade de negócio > http://www.franquiasargohost.net > --------------------------- > > > _______________________________________________ > [email protected] > http://www.codeigniter.com.br > http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br > > --------------------------- > Oportunidade de negócio > http://www.franquiasargohost.net > --------------------------- > > > > _______________________________________________ > [email protected] > http://www.codeigniter.com.br > http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br > > --------------------------- > Oportunidade de negócio > http://www.franquiasargohost.net > --------------------------- > > > _______________________________________________ > [email protected] > http://www.codeigniter.com.br > http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br > > --------------------------- > Oportunidade de negócio > http://www.franquiasargohost.net > --------------------------- > > > > _______________________________________________ > [email protected] > http://www.codeigniter.com.br > http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br > > --------------------------- > Oportunidade de negócio > http://www.franquiasargohost.net > --------------------------- > > > _______________________________________________ > [email protected] > http://www.codeigniter.com.br > http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br > > --------------------------- > Oportunidade de negócio > http://www.franquiasargohost.net > --------------------------- > > > > _______________________________________________ > [email protected] > http://www.codeigniter.com.br > http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br > > --------------------------- > Oportunidade de negócio > http://www.franquiasargohost.net > --------------------------- > > > _______________________________________________ > [email protected] > http://www.codeigniter.com.br > http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br > > --------------------------- > Oportunidade de negócio > http://www.franquiasargohost.net > --------------------------- > > > > _______________________________________________ > [email protected] > http://www.codeigniter.com.br > http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br > > --------------------------- > Oportunidade de negócio > http://www.franquiasargohost.net > --------------------------- > >
_______________________________________________ [email protected] http://www.codeigniter.com.br http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br --------------------------- Oportunidade de negócio http://www.franquiasargohost.net ---------------------------

