display image in a particular width and height
Posted: Fri Jan 02, 2009 7:09 am
Hello
i am displaying images from a paticular folder,the code is working fine but i want to display all the image in same width and height...the code for displaying images is givn below
I am calling the php pages as below
THANK YOU IN ADVANCE....
i am displaying images from a paticular folder,the code is working fine but i want to display all the image in same width and height...the code for displaying images is givn below
Code: Select all
<?php
// define absolute path to image folder
$image_folder = 'IMAGE FOLDER NAME';
// get the image name from the query string
if (isset($_GET['pic']) && basename($_GET['pic']) == $_GET['pic'])
{
$pic = $image_folder.$_GET['pic'];
if (file_exists($pic) && is_readable($pic))
{
// get the filename extension
$ext = substr($pic, -3);
// set the MIME type
switch ($ext)
{
case 'jpg': $mime = 'image/jpeg';
break;
case 'gif': $mime = 'image/gif';
break;
case 'png': $mime = 'image/png';
break;
default: $mime = false;
}
// if a valid MIME type exists, display the image
// by sending appropriate headers and streaming the file
if ($mime)
{
header('Content-type: '.$mime);
header('Content-length: '.filesize($pic));
$file = @ fopen($pic, 'rb');
if ($file)
{
fpassthru($file); exit;
}
}
}
}
?>Code: Select all
FILENAME.php?pic=$imgname