Home | History | Annotate | Download | only in ps
      1 #!/usr/bin/perl
      2 #
      3 # Test Reading Postscript images
      4 #
      5 # Contributed by Bob Friesenhahn <bfriesen (at] simple.dallas.tx.us>
      6 #
      7 
      8 BEGIN { $| = 1; $test=1; print "1..3\n"; }
      9 END {print "not ok $test\n" unless $loaded;}
     10 use Image::Magick;
     11 $loaded=1;
     12 
     13 require 't/subroutines.pl';
     14 
     15 chdir 't/ps' || die 'Cd failed';
     16 
     17 #
     18 # 1) Test reading Postscript
     19 #
     20 $image=Image::Magick->new;
     21 $x=$image->ReadImage('input.ps');
     22 if( "$x" ) {
     23   print "ReadImage: $x\n";
     24   print "not ok $test\n";
     25 } else {
     26     print "ok $test\n";
     27 }
     28 undef $image;
     29 
     30 
     31 #
     32 # 2) Test reading Encapsulated Postscript
     33 #
     34 ++$test;
     35 $image=Image::Magick->new;
     36 $x=$image->ReadImage('input.eps');
     37 if( "$x" ) {
     38   print "ReadImage: $x\n";
     39   print "not ok $test\n";
     40 } else {
     41     print "ok $test\n";
     42 }
     43 undef $image;
     44 
     45 #
     46 # 3) Test rendering using a Postscript font
     47 #
     48 ++$test;
     49 $font   = 'helvetica';
     50 
     51 $image=Image::Magick->new;
     52 $x=$image->Set(font=>"$font", pen=>'#0000FF', dither=>'False');
     53 if( "$x" ) {
     54   print "$x\n";
     55   print "not ok $test\n";
     56 } else {
     57   $x=$image->ReadImage('label:The quick brown fox jumps over the lazy dog.');
     58   if ( "$x" ) {
     59     print "ReadImage: $x\n";
     60     # If server can't be accessed, ImageMagick returns this warning
     61     # Warning 305: Unable to open X server
     62     $x =~ /(\d+)/;
     63     my $errorCode = $1;
     64     if ( $errorCode > 0 ) {
     65       print "not ok $test\n";
     66     } else {
     67       print "ok $test\n";
     68     }
     69   } else {
     70     print "ok $test\n";
     71   }
     72 }
     73 undef $image;
     74