title: Magickwand conversion to TIFF&CCITT group 4 compression gives uncompressed image
body: <p>Trying to convert a 24 bpp bitmap to black &amp; white TIFF with CCITT group 4 compression.
  The result is a TIFF 1 bpp image as expected but it is uncompressed.</p>
  
  <p>I'm using FreePascal which has magickwand bindings and the status is never MagickFalse:</p>
  
  <pre><code>MagickWandGenesis;
  wand := NewMagickWand;
  try
    status := MagickReadImage(wand,PChar(InputFile));
    if (status = MagickFalse) then HandleError;
  
    status := MagickSetImageFormat(wand,'TIFF');
    if (status = MagickFalse) then HandleError;
  
    // convert to black &amp; white/lineart
    status := MagickSetImageType(wand,BilevelType);
    if (status = MagickFalse) then HandleError;
  
    // Group4Compression seems defined as 4 which 
    // apparently doesn't match imagemagick source. Bug:
    //http://mantis.freepascal.org/view.php?id=26723
    status := MagickSetImageCompression(wand,CompressionType(7)); //was Group4Compression
    if (status = MagickFalse) then HandleError;
  
    // Apparently set(image)compresionquality and
    // stripimage are necessary to actually compress
    status := MagickSetImageCompressionQuality(wand,0);
    if (status = MagickFalse) then HandleError;
    status := MagickStripImage(wand);
    if (status = MagickFalse) then HandleError;
  
    status := MagickWriteImage(wand,PChar(OutputFile));
    if (status = MagickFalse) then HandleError;
  
  finally
    wand := DestroyMagickWand(wand);
  end;
  MagickWandTerminus;
  </code></pre>
  
  <p>Source image at <a href="http://filehorst.de/d/bmqjzDuB" rel="nofollow">http://filehorst.de/d/bmqjzDuB</a></p>
  
  <p>Original (faulty) program source code at <a href="http://filehorst.de/d/bluhjivq" rel="nofollow">http://filehorst.de/d/bluhjivq</a></p>
  
  <p>Original (faulty) output image at <a href="http://filehorst.de/d/bhlbjHgp" rel="nofollow">http://filehorst.de/d/bhlbjHgp</a></p>
  
  <p>What am I doing wrong?</p>
  
  <p>Edit: solved; got the solution off-site: the CompressionType enum in the FreePascal bindings were probably out of date - Group4Compression was 4 (IIRC) while it should be 7.</p>
  
  <p>I'll give the bounty to Mark Setchell as his answer was a necessary part of the solution. Source code above updated with correct version.</p>