Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Biel.

Reduzir código

Recommended Posts

Boa noite a todos. Direto ao ponto. Pessoal,
gostaria que imagecreatefromjpeg | imagecreatefrompng | imagecreatefromgif
ficasse dentro de uma só tag e não em tags separadas conforme exemplo abaixo
<?php 
$temp    = $_FILES['imagem']['tmp_name']; 
$jpeg     = imagecreatefromjpeg($temp); //jpeg
imagecopyresampled($jpeg);
?>
...
<?php
$temp    = $_FILES['imagem']['tmp_name']; 
$png     = imagecreatefrompng($temp);  //png
imagecopyresampled($png);
?>

...

<?php
$temp  = $_FILES['imagem']['tmp_name']; 
$gif   = imagecreatefromgif($temp); //gif
imagecopyresampled($gif);
?>

...

<table width="344" border="0" cellpadding="5" cellspacing="5">


  <tr>
    <td width="96" height="34" align="right">Buscar_imagem</td>
    <td width="218"><input type="file" name="imagem" required  value="" /></td>
  </tr>
    
    <tr>
    <td height="70" colspan="3" valign="bottom"><input type="submit" name="botaocss"  value="Salvar Cadastro" /></td>
  </tr> 


</table>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

Verifique qual o mime-type da imagem e crie uma função, apesar que já existe de kilo na net

<?php // RAY_temp_andrey.php
error_reporting(E_ALL);

$file = 'http://laprbass.com/RAY_EE_images/headshot.png';
$file = 'http://laprbass.com/RAY_EE_images/headshot.jpg';
$file = 'http://laprbass.com/RAY_EE_images/headshot.gif';

$what = getimagesize($file);

switch(strtolower($what['mime']))
{
    case 'image/png':
        $img = imagecreatefrompng($file);
        break;
    case 'image/jpeg':
        $img = imagecreatefromjpeg($file);
        break;
    case 'image/gif':
        $img = imagecreatefromgif($file);
        break;
    default: die();
}
$new = imagecreatetruecolor($what[0],$what[1]);
imagecopy($new,$img,0,0,0,0,$what[0],$what[1]);

header('Content-Type: image/jpeg');
imagejpeg($new);
imagedestroy($new);

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.