TIFF Compression

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
MGSteve

TIFF Compression

Post by MGSteve »

I'm generating a 3355 x 2410 image and I need to have layers in the image, so as IM can't create layers within the PSD format at the moment, I'm having to use TIFF.

Problem is, it doens't seem to want to use a compression format at all.

Here's the code, but whatever compression format I try and use, it turns out a 48MB file.

Code: Select all

        $wPreview = $Preview->GenerateMaster($MasterFile,$ImageSetup->Fields,false);
        $Res = MagickSetImageFormat($wPreview,'TIFF');
        $Res = MagickSetImageCompression($wPreview,MW_ZIPCompression);
        MagickWriteImage($wPreview,"$ImageDir/$OrderID-{$Order->LineItems->Rows[$nCount]['order_line_id']}-production.tiff");
        DestroyMagickWand($wPreview);
Any idea as to why it won't accept any compression settings?
MGSteve

Re: TIFF Compression

Post by MGSteve »

Also, if I manually convert the output (i.e. convert 25-23-production.tiff -compress lzw test.tiff) then it works fine, both with LZW and ZIP compression.

It just fails to use any compression when saving through MagickWand. The call to MagickSetImageCompression return true, by the way.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: TIFF Compression

Post by magick »

The following code returned LZW and Zip compression for us as expected. We're using ImageMagick 6.5.1-0 and MagickWand for PHP 1.0.8:

  • tiffinfo production.tiff
    TIFF Directory at offset 0x22b0 (8880)
    Image Width: 70 Image Length: 46
    Resolution: 72, 72 pixels/inch
    Bits/Sample: 8
    Compression Scheme: LZW
    Photometric Interpretation: RGB color
    FillOrder: msb-to-lsb
    Orientation: row 0 top, col 0 lhs
    Samples/Pixel: 3
    Rows/Strip: 39
    Planar Configuration: single image plane
    Page Number: 0-1
    DocumentName: production.tiff
    Software: ImageMagick 6.5.1-1 2009-04-02 Q16 OpenMP http://www.imagemagick.org
    Predictor: horizontal differencing 2 (0x2)

Code: Select all

<?php
   $magick_wand = NewMagickWand();
   $status = MagickReadImage($magick_wand,'rose.jpg');
   if ($status == 0) {
     echo 'Error 1: '.MagickGetExceptionString($magick_wand);
   }
   $status = MagickSetImageFormat($magick_wand,'TIFF');
   if ($status == 0) {
     echo 'Error 2: '.MagickGetExceptionString($magick_wand);
   }
   $status = MagickSetImageCompression($magick_wand,MW_LZWCompression);
   if ($status == 0) {
     echo 'Error 3: '.MagickGetExceptionString($magick_wand);
   }
   $status = MagickWriteImage($magick_wand,"production.tiff");
   if ($status == 0) {
     echo 'Error 4: '.MagickGetExceptionString($magick_wand);
   }
   DestroyMagickWand($magick_wand);
?>
Post Reply