PHPBuilder - Image Properties Viewer



RSS Twitter
Snippets Graphics

Image Properties Viewer

by: Shankar Ramachandran
|
May 18, 2004

Version: 1.0

Type: Full Script

Category: Graphics

License: GNU General Public License

Description: This is a basic code snippet,useful for PHP newbies, which lets the user browse through the local system and get the dimensions of gif/jpg files along with viewing the image. Compatible with the PHP 4.0/Apache 3.0 and later versions.



<html>
<title> Image Properties Viewer </title>
  <body>
  <center>
   <h2> Image Properties Viewer </h2>
   <form action="<?php echo $PHP_SELF ?>">
      <input type="file" name="str"> <br> <br>
      <input type="submit" name="submit" value="Submit" >
  </center>
 </form>
  </body>
</html>

<?php
if ($submit)
{

$img = str_replace('\\\\','\\',$str); /*to remove the double backslash sent by default*/
$h = getimagesize($str);
   if ($str="")
   {
     echo " <center> <b> Please enter a valid image! </b> </center> ";
   }
   else
   { 
   echo "<center> <table border='5' bordercolor='black'>";
   echo "<tr bgcolor='#efefef'> <td align=center> <b> The Image </b> </td>";
   echo " <td align=center> <b>  Image Dimensions </b> </td> </tr>";
   echo "<tr> <td align=center> <b> <img src = '$img'> </b> </td> ";
   echo " <td align=center > <b>  $h[3]  </b> </td> </tr>";
   echo "</table>";
   echo "</center>";
   echo "<br>";
   }
}

?>

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Shankar Ramachandran

Comment:



Comment:

(Maximum characters: 1200). You have characters left.