Using Imagick fill patterns results in blank text

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
Morgon

Using Imagick fill patterns results in blank text

Post by Morgon »

Hi all,

I've been trying to implement fill patterns, as listed in Example 4 on http://www.php.net/manual/en/imagick.examples-1.php.
Unfortunately, I am getting blank text when the script executes (the example creates a border around the image which works, so it's not a general issue), and I'm not sure what I can do to change it.

I thought it might have been my newer software version (ImageMagick v6.6.1), as I have another machine which works fine using ImageMagick 6.5.8-10. However, even after downgrading, I continue to have this problem.

Is there anything else that I should be checking? I contacted Mikko, the author of Imagick, who suggested it might have been a configuration issue; but I have since removed all traces of other/older ImageMagick builds and re-installed 6.6.1, so I don't believe there should be any conflicts or confusion.

Thanks!
DJ Mike
Posts: 33
Joined: 2010-06-29T19:07:53-07:00
Authentication code: 8675308

Re: Using Imagick fill patterns results in blank text

Post by DJ Mike »

Here is another example

Code: Select all

<?php
# path to font
$font = "../../fonts/lokicola.ttf";
# text of annotation
$text = "DJ Mike";
# bgcolor
$bg = "#fad888";
# font size
$fontsize = 100;
# path to fill image
$pattern = new Imagick( '../../images/marb015.jpg' );
# offset to adjust image position
$offset = 14;
#########################################

# create imagick object
$pallete = new Imagick();
# give it size and color attributes
$pallete->newimage(375,140, "$bg");

# Create imagickdraw object
$draw = new ImagickDraw();
$draw->setfont("$font"); # set font

#### Start a new pattern called "marble" ####
$draw->pushPattern( 'marble'  , 0  , 0  , 360  , 270 );
# composite fill image over it
$draw->composite( Imagick::COMPOSITE_OVER, 0, 0, 375, 140, $pattern  );
# end pattern definition
$draw->popPattern();
#############################################

# Set pattern called "marble" as the fill
$draw->setFillPatternURL( '#marble' );
# set gravity
$draw->setgravity(imagick::GRAVITY_CENTER); 
# set font size
$draw->setFontSize( $fontsize );
# annotate
$draw->annotation( 0, $offset, "$text" );

# apply draw object to imagick object
$pallete->drawImage( $draw );
# give it a raised border
$pallete->raiseImage( 10, 10, 140, 100, TRUE);
# set format
$pallete->setImageFormat( 'png' );
# Output the image 
header( "Content-Type: image/png" );
echo $pallete;
?>
Imagick::setFillPatternURL
http://eclecticdjs.com/mike/tutorials/p ... ernurl.php
DJ Mike's Tutorials: PHP
ImageMagick Functions
http://eclecticdjs.com/mike/tutorials/p ... /index.php
Post Reply