Saturday, October 8, 2011

Displaying tiff image in Browsers

As Tiff image is requires Quick Time Plugin, So it is Working well with Safari browser like as normal png or jpg image, But in firefox or IE or Chrome Does not support it directly. They need Quick Time Plugin to be install on System then We can embade them as

<embed width=75 height=75 src="image.tif" type="image/tiff" negative=yes>

Other Way to display is to convert image in PNG/JPG format using Imagick, in php

<?php
try
{
// Saving every page of a <strong>TIFF</strong> separately as a JPG thumbnail
$images = new Imagick("testing.tif");
foreach($images as $i=>$image) {
// Providing 0 forces thumbnail Image <strong>to</strong> maintain aspect ratio
$image->thumbnailImage(768,0);
$image->writeImage("page".$i.".jpg");
echo "<img src='page$i.jpg' alt='images' ></img>";
}
$images->clear();
}
catch(Exception $e)
{
echo $e->getMessage();
}
?>