|
|
|
This script displays the image passed as an arguament in proportion to its original size if it is larger than $max which is again passed an argument.
Here $file should be a complete path + file name suchas:
/usr/home/leapinglangoor/pics/lagoors.jpeg
$max is the maximum X or Y an image can have
| <?php
function show_thumbnail( $file, $max )
{
$size = getimagesize( $file );
if ( $size[0] <= $max && $size[1] <= $max )
{
$ret = '<img src="'.$file.'" '.$size[3].' border="0">';
}
else
{
$k = ( $size[0] >= $size[1] ) ? $size[0] / $max : $size[1] / $max;
$ret = '<a href="javascript:;" onClick="window.open(\'image.php?img=';
$ret .= $file.'\',\'\',\'width='.$size[0];
$ret .= ',height='.$size[1].'\')">';
$ret .= '<img src="'.$file.'" width="'.floor($size[0]/$k).'" height="'.floor($size[1]/$k).'" border="0" alt="View full-size image"></a>';
}
return $ret;
}
?> | |
Here is the code of 'image.php':
| <html>
<head>
<title>Image</title>
</head>
<body leftmargin="0" topmargin="0">
<?php
echo ( is_file($_GET['img'] ) ? '<a href="#" onClick="window.close();"><img src="'.$_GET['img'].'" border="0" alt="Close window"></a>' : 'Invalid image filename, or no filename entered. <a href="#" onClick="window.close();">Close window</a>.' );
?>
</body>
</html> | | |
|
| Random Image Display Categories : PHP, Filesystem, Graphics, HTML and PHP | | | Creating thumbnails from MySQL Blobs online Categories : PHP, MySQL, Graphics, HTML and PHP, Databases | | | webcam cam view image ispy browser independant Categories : Graphics, HTML, HTML and PHP, PHP | | | Functions for loading images into a MySQL database and displaying them. Categories : Graphics, HTML and PHP, MySQL, PHP, Databases | | | Upload images restricted by pixel size (Picture width and Picture Height) Categories : PHP, HTML and PHP, Graphics | | | Snipe.Net's Web Design Color Scheme Previewer- Allows uses to input hex
codes for their text, background, and link colors, and preview the color
scheme with their background image. Example:
http://www.snipe.net/tech/snipeschool/hex.php3 Categories : PHP, HTML and PHP, General, Graphics, HTML | | | PHPixel - output of 1 pixel transparent/colored gif for counters etc. Categories : PHP, Graphics, HTML and PHP | | | Barcodes On The Fly With GD Categories : Ecommerce, Graphics, HTML and PHP, PHP | | | Simple PHP/3 Access Counter (using GD and DBM functions) Categories : Databases, PHP, Graphics, HTML and PHP, dBase | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality. Categories : PHP, GD image library, Graphics | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | | | Tag content retrieval from websites with preg_match Categories : PHP, Regexps, Arrays, HTML and PHP | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET Categories : Algorithms, HTML and PHP, PHP, Variables | |
|
|
|