setFillPatternURL 'Unable to set fill pattern URL'

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
jhb
Posts: 4
Joined: 2012-10-10T01:53:49-07:00
Authentication code: 67789

setFillPatternURL 'Unable to set fill pattern URL'

Post by jhb »

I'm trying to use the pecl "imagick" function setFillPatternURL, see http://pastebin.com/cquGJhRm

When running the script I get 'Unable to set fill pattern'.

# php -f setfillpatternurl.php
PHP Fatal error: Uncaught exception 'ImagickDrawException' with message
'Unable to set fill pattern URL' in /var/www/html/setfillpatternurl.php:23
Stack trace:
#0 /var/www/html/setfillpatternurl.php(23):
ImagickDraw->setfillpatternurl('#gradient')
#1 {main}
thrown in /var/www/html/setfillpatternurl.php on line 23


Can anybody tell me what I am doing wrong?

The PNG-image "header_colourmask.png" is a standard PNG24


Thanks in advance.


Best regards
Jonas


System information:

Operating system: CentOS 5.8

PHP:

# php -v
PHP 5.3.3 (cli) (built: Jun 27 2012 12:25:48)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


ImageMagick:

# identify -list configure

Path: /usr/lib64/ImageMagick-6.2.8/config/configure.xml

Name Value
-------------------------------------------------------------------------------
CC gcc
CFLAGS -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wall
-pthread
CONFIGURE ./configure --build=x86_64-redhat-linux-gnu
--host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu
--program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin
--sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share
--includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec
--localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --with-modules --with-perl
--with-x --with-threads --with-magick_plus_plus --with-gslib --with-wmf
--with-lcms --with-rsvg --with-xml --with-perl-options=INSTALLDIRS=vendor
CC='gcc -L/builddir/build/BUILD/ImageMagick-6.2.8/magick/.libs'
LDDLFLAGS='-shared -L/builddir/build/BUILD/ImageMagick-6.2.8/magick/.libs'
--with-windows-font-dir=/usr/share/fonts/default/TrueType --without-dps
COPYRIGHT Copyright (C) 1999-2005 ImageMagick Studio LLC
CPPFLAGS -I/usr/include
CXX g++
CXXFLAGS -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -pthread
DEFS -DHAVE_CONFIG_H
DISTCHECK_CONFIG_FLAGS 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64
-mtune=generic' --with-quantum-depth=16 --with-dps=no --with-fpx=no
--with-fontpath=
--with-windows-font-dir==/usr/share/fonts/default/TrueType
EXEC-PREFIX /usr
HOST x86_64-redhat-linux-gnu
LDFLAGS -L/usr/lib64 -L/usr/lib64 -lfreetype -L/usr/lib
LIB_VERSION 0x628
LIB_VERSION_NUMBER 6,2,8,0
LIBS -lMagick -llcms -ltiff -lfreetype -ljpeg -lfontconfig -lXext
-lSM -lICE -lX11 -lXt -lbz2 -lz -lpthread -lm -lpthread
NAME ImageMagick
PCFLAGS
PREFIX /usr
QuantumDepth 16
RELEASE_DATE 05/07/12
VERSION 6.2.8
WEBSITE http://www.imagemagick.org


PECL imagick:

# pecl info imagick

Warning: date(): It is not safe to rely on the system's timezone settings.
You are *required* to use the date.timezone setting or the
date_default_timezone_set() function. In case you used any of those
methods and you are still getting this warning, you most likely misspelled
the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST'
instead in PEAR/Command/Registry.php on line 983
About pecl.php.net/imagick-3.0.1
================================
Release Type PECL-style PHP extension (source code)
Name imagick
Channel pecl.php.net
Summary Provides a wrapper to the ImageMagick library.
Description Imagick is a native php extension to create and
modify images using the ImageMagick API.
This extension requires ImageMagick version
6.2.4+ and PHP 5.1.3+.

IMPORTANT: Version 2.x API is not compatible
with earlier versions.
Maintainers Mikko Koppanen <mkoppanen@php.net> (lead)
Scott MacVicar <scottmac@php.net> (lead)
Release Date 2010-11-18 21:16:01
Release Version 3.0.1 (stable)
API Version 3.0.1 (stable)
License PHP License (http://www.php.net/license)
Release Notes - Fixed PECL bug #17244
Required Dependencies PHP version 5.1.3
PEAR installer version 1.4.0 or newer
package.xml version 2.0
Last Modified 2012-10-10 10:02
Last Installed Version - None -
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: setFillPatternURL 'Unable to set fill pattern URL'

Post by Bonzo »

The first thing I would do is reduce you code to the basics and use a pattern already created as you have quite a lot going on.
jhb
Posts: 4
Joined: 2012-10-10T01:53:49-07:00
Authentication code: 67789

Re: setFillPatternURL 'Unable to set fill pattern URL'

Post by jhb »

This is as basic as I can make it (I need the custom font)

How would you apply a already existing pattern? I've tried some of the patterns listed in the page below:
http://www.imagemagick.org/script/formats.php

Code: Select all

Uncaught exception 'ImagickDrawException' with message 'URLNotFound `#bricks''

Code: Select all

$text = "Hello World!";
$image = new Imagick();
$draw = new ImagickDraw();
$color = new ImagickPixel('#fff');
$background = new ImagickPixel('none');

$draw->setFontSize(32);
$draw->setFont('Dbbrnms.ttf');
$draw->setFillColor($color);

$draw->setFillPatternURL("#bricks");

$metrics = $image->queryFontMetrics($draw, $text);

$draw->annotation(0, $metrics['ascender'], $text);

$image->newImage($metrics['textWidth'], $metrics['textHeight'], $background);
$image->setImageFormat('png');
$image->drawImage($draw);

header("Content-Type: image/png");
echo $image;
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: setFillPatternURL 'Unable to set fill pattern URL'

Post by Bonzo »

I do not quite know what you want but this example works for me except I have to save the image and not display it.

http://valokuva.org/?p=102

I tried your example and had errors about not a relative URL or similar - personaly I hate Imagick.
jhb
Posts: 4
Joined: 2012-10-10T01:53:49-07:00
Authentication code: 67789

Re: setFillPatternURL 'Unable to set fill pattern URL'

Post by jhb »

The example at valokuva.org dosn't work for me. Still get

Code: Select all

Fatal error: Uncaught exception 'ImagickDrawException' with message 'Unable to set fill pattern URL'
I find it interesting that you are able to get the example to work. Whats your versions of the programs? (ImageMagick, IMagick, PHP, etc.) I guess something has changed in either ImageMagick API or Imagick.

If you hate IMagick, what do you use then? :)
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: setFillPatternURL 'Unable to set fill pattern URL'

Post by Bonzo »

As you say there must be some difference in my setup - I will check it out later.
If you hate IMagick, what do you use then?
I use the command line with exec() there is a link in my signature.
jhb
Posts: 4
Joined: 2012-10-10T01:53:49-07:00
Authentication code: 67789

Re: setFillPatternURL 'Unable to set fill pattern URL'

Post by jhb »

I just booted a fresh CentOS 6.3 and installed php, ImageMagick, Imagick (thru pecl install imagick), and the example from valokuva.org worked.

I'll now try to figure out whats the differences in php, ImageMagick, Imagick, etc. between CentOS 5.8 and CentOS 6.3 are. If anybody already know what these differences are, feel free to share them :)
Post Reply