Page 1 of 1
Tif with transparent background
Posted: 2010-06-28T00:51:02-07:00
by btam
I have a tif image with transparent background.
I try to copy the image with the following code, the background color become white in the new image
$im = new Imagick('image.tif');
$im->setImageFormat("tif");
$im->writeImage('new_image.tif');
How to handle transparent tif image?
Re: Tif with transparent background
Posted: 2010-06-28T10:58:17-07:00
by fmw42
try enabling the matte channel before writing
Re: Tif with transparent background
Posted: 2010-06-28T11:20:44-07:00
by btam
I've tried
$im->setImageMatte(true);
$im->setFormat("tiff");
$im->writeImage($image);
still no luck
Re: Tif with transparent background
Posted: 2010-06-28T11:41:48-07:00
by fmw42
what version of IM and what version of Imagick? perhaps you need to upgrade? I am not really an expert on Imagick, but I can see if it works for me.
Re: Tif with transparent background
Posted: 2010-06-28T11:54:57-07:00
by fmw42
This works perfectly fine for me.
<?php
// Input image name
$image = "logo2t.tif";
// Output image name
$output = "logo2t2.tif";
try
{
$im = new Imagick();
$im->readImage( $image );
$im->writeImage( $output );
}
catch(Exception $e)
{
echo $e->getMessage();
}
// Delete the image created
//unlink($output);
echo "<img src=\"$output\" border=1>";
?>
But when I display the image to my browser, the transparent areas are white, because the background of the page is white. But when I copy the image to my desktop and display it in some other tool that is capable of showing the transparent areas, they look fine (transparent).
PHP Version 5.1.6
IM Version 6.6.2.9 Q16
Imagick 3.0.0RC1