PHP graphic manipulation help!

I am building an application that creates a label for a manufacturing company… it finds an appropriate font size for given text, and then draws it and displays the image as a bmp(it is required to be a bmp). That is all fine and dandy and working correctly. The problem is that the label must have a depth of 2 bits for it to work correctly on their machine…I am using the following code, but cannot get a bit depth lower than 24. iMagick and GD are both available on the server.

$text = $_GET['text'];

if (isset($text)) {

      $image = new Imagick();
      $image->setResolution(71.5, 71.5);
      $image->newImage(160, 40, new ImagickPixel('black'));

      $draw = new ImagickDraw();
      $draw->setStrokeColor(new ImagickPixel('black'));
      $draw->rectangle(0, 0, 159, 39);
      $font_size = 25;
      $font_name = 'arial.ttf';
         $bbox=imagettfbbox($font_size, 0, $font_name, stripcslashes($text));
         $right_text = $bbox[2];
         $left_text = $bbox[0];
         $width_text = $right_text - $left_text;
         $height_text = abs($bbox[7] - $bbox[1]);
      while ($font_size>9 && ($height_text>40 || $width_text>160));
      if ($height_text>40 || $width_text>160 || $font_size<10)
         echo 'The text given will not fit on the label.<br />';
         $draw->setGravity (Imagick::GRAVITY_CENTER);
         $draw->annotation(0, 0, stripcslashes($text));
         $image->blackthresholdImage( "#999999" );
         $image->whitethresholdImage( "#999999" );


         echo '<img src="flavor_labels/'.$text.'.bmp" /><br /><p>Right click this image and click Save As or Save Image As.  <br />Enter in the desired label name and save it to the desired destination.</p>';



Sorry if this is completely irrelevant. However does this help?

I do not think GD supports bmp.

You may not need the code from the link Tribal_01 posted to work in Imagick as all the operators are not supported.
I use php and the command line with exec( ).