← Tutoriais

[PHP] Detectar se o Thumbnail é aceitavel!

Lida 3322 vezes

Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Bem, com este script vamos detectar se a largura e se a altura da imagem são menores que 250, senão não vai dár para thumbnail!

index.html:

Código: [Seleccione]
<HTML>
<HEAD>
 <TITLE>Verificar Thumbnail!</TITLE>
</HEAD>
<BODY>
  <form action="imagem.php">
  <input type="text" name="imagem" size="20">
  <input type="submit" value="Verificar Thumbnail">
</BODY>
</HTML>


imagem.php :

Código: [Seleccione]
<?php
$url 
$_REQUEST['imagem'&#93;;
$img = @imagecreatefromgif&#40;$url&#41;;

if &#40;$img&#41; $img_height = imagesy&#40;$img&#41;;
if &#40;$img&#41; $img_weith = imagesx&#40;$img&#41;;

if &#40;$img_height < 250 and $img_weith < 250&#41;
&#123;
echo"Thumbnail aceite!";
&
#125;
elseif &#40;$img_height > 250 and $img_weith > 250&#41;
&#123;
echo&#40;"Tanto a altura como a largura são maiores que 250, o tamanho máximo é 250"&#41;;
&#125;
elseif &#40;$img_height > 250 and $img_weith < 250&#41;&#123;
echo&#40;"A altura é maior que 250"&#41;;
&#125;
elseif &#40;$img_height < 250 and $img_weith > 250&#41;&#123;
echo&#40;"A largura é maior que 250"&#41;;
&#125;
elseif &#40;$img_height > 250&#41;&#123;
echo&#40;"A altura é maior que 250"&#41;;
&#125;
else echo&#40;"Imagem Invalida!"&#41;;
?>


Agora correm o index.html e colocam o link duma imagem!


Exercicio:

Criem um script que mostre a altura e a largura!

Exemplo:

Largura: 120
Altura: 140

Cumps
Offline

fpware 
Fundador
Mensagens 15318 Gostos 7
Troféus totais: 38
Trófeus: (Ver todos)
Linux User Mobile User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5

Está porreiro, muito obrigado cenourinha!
Offline

asturmas 
Administrador
Mensagens 19734 Gostos 50
Feedback +2

Troféus totais: 39
Trófeus: (Ver todos)
Mobile User Windows User Super Combination Combination Topic Starter 100 Poll Votes 50 Poll Votes 10 Poll Votes Poll Voter Poll Starter

Mto interesante
Amanha tento faxer o exercicio lol