// Sample call http://172.26.50.202/imagecache.php?scan_date=20101203&item_key=IMPORT_7cb88ca5813f4e8c97a8cb797d5291cf2&image_name=00000001.tif&format=png&width=0&height=600&orientation=180
// This vlaue should point the the home of the image cache. The user IUSR must have read access to this directory.
$image_cache_home = "F:\Capture\ImageCache";
// parse url
$scan_date = $_GET['scan_date'];
$item_key = $_GET['item_key'];
$image_name = $_GET['image_name'];
$format = $_GET['format'];
$width = $_GET['width'];
$height = $_GET['height'];
$orientation = $_GET['orientation'];
// assemble full path to image
$image_path = $image_cache_home . "\\" . $scan_date . "\\" . $item_key . "\\" . $image_name;
// load the image
$im = new Imagick( $image_path );
// rotate the image.
if( $orientation > 0 ) {
$im->rotateImage(new ImagickPixel(), $orientation);
}
// adjust the size ( a value of 0, will retain the aspect ratio)
if( $width > 0 || $height > 0 ) {
$im->resizeImage($width, $height, Imagick::FILTER_POINT, 1);
}
// change format to png
$im->setImageFormat( $format );
// output the image to the browser as a png
if( $format == "pdf" )
{
header( "Content-Type: application/pdf" );
}
elseif( $format == "jpg" )
{
header( "Content-Type: image/jpg" );
}
elseif( $format == "png" )
{
header( "Content-Type: image/png" );
}
elseif( $format == "tif" )
{
header( "Content-Type: image/tiff" );
}
elseif( $format == "gif" )
{
header( "Content-Type: image/gif" );
}
// send the image
echo $im;
// cleanup
$im->clear();
$im->destroy();
?>