Page 1 of 1
linecap and linejoin properties in Perl Magick?
Posted: 2007-03-20T01:19:54-07:00
by burgerguy
I've searched the boards, Google, the docs... The only real mentions of setting the linecap and linejoin properties for the stroke of a shape/path seem to be in the MVG section, but it seems to imply that these functions are or should be available in PerlMagick. Thing is, for the life of me, I can't find any direct mention or example of their usage or even availability in PerlMagick.
Does PerlMagick just not have these hooks or are they just not well documented?
If it's the latter, how do I call them in a Draw object?
Re: linecap and linejoin properties in Perl Magick?
Posted: 2007-03-20T06:32:56-07:00
by magick
PerlMagick does not support all the drawing attributes. For unsupported attributes, write your drawing requirements as MVG or SVG and interpret with ReadImage(). See
http://www.imagemagick.org/script/magic ... aphics.php for details.
Re: linecap and linejoin properties in Perl Magick?
Posted: 2007-03-20T11:01:56-07:00
by burgerguy
ReadImage() for PerlMagick isn't well documented. So I feel like I'm poking around in the dark here.
Let's say I created a string called shapedef, with a vector shape description in MVG format. Would I invoke it with ReadImage('mvg:$shapedef')?
Can you point me to usage rules or references for ReadImage() in PerlMagick?
Thanks,
Greg
Re: linecap and linejoin properties in Perl Magick?
Posted: 2007-03-20T11:14:13-07:00
by magick
If you want to read an in-memory string, use ReadBlob(), otherwise you need to create a temporary file with your MVG commands. Suppose its called mycommands, use this:
- $image->Read("mvg:mycommands");
A better solution is a patch we're going to add today to permit MVG strings directly in the Draw() method. Something like this:
- $image->Draw('vector-graphics'=>"...");
This patch will be available sometime tommorrow in ImageMagick 6.3.3-3 Beta.
Re: linecap and linejoin properties in Perl Magick?
Posted: 2007-03-20T12:42:22-07:00
by burgerguy
magick wrote:
If you want to read an in-memory string, use ReadBlob(), otherwise you need to create a temporary file with your MVG commands. Suppose its called mycommands, use this:
- $image->Read("mvg:mycommands");
A better solution is a patch we're going to add today to permit MVG strings directly in the Draw() method. Something like this:
- $image->Draw('vector-graphics'=>"...");
This patch will be available sometime tommorrow in ImageMagick 6.3.3-3 Beta.
I can't run an ImageMagick beta on a production server. Just not willing to take that risk.
As well, a single image could have 50 shapes. I can't have 50 external files per image. It's just unmanageable.
I'd much rather have the shapes as strings. Since the path definition for Draw is pretty much the same as the path definition for SVG, converting the Draw code to SVG code programmatically wouldn't be a big deal.
So, two questions.
1: Would the code need to be a shape definition in SVG format or an entire SVG file from beginning to end?
2: Would I invoke it simply as ReadBlob($shapedef) or ReadBlob('svg:$shapedef') or something else altogether?
Thanks,
Greg
Re: linecap and linejoin properties in Perl Magick?
Posted: 2007-03-20T16:06:08-07:00
by magick
Here's an example that converts a set of MVG commands to an image:
Code: Select all
#!/usr/bin/perl
use Image::Magick;
my $blob = q/push graphic-context
push defs
push clip-path -605496458
push graphic-context
path 'M0,0 l425.196850393701,0 l0,70.8661417322835
l-425.196850393701,0 l0,-70.8661417322835z'
pop graphic-context
pop clip-path
pop defs
clip-path -605496458
scale 0.354330708661417,0.354330708661417
push graphic-context
translate 200.0,75.0
push graphic-context
stroke "black"
stroke-linecap butt
stroke-width 70.0
line -125,0 125,0
pop graphic-context
push graphic-context
stroke "#ffcccc"
stroke-width 5.0
line -125,0 125,0
pop graphic-context
push graphic-context
fill "#ffcccc"
stroke "none"
circle -125,0 -117,0
pop graphic-context
push graphic-context
fill "#ffcccc"
stroke "none"
circle 125,0 133,0
pop graphic-context
push graphic-context
font-family 'Verdana'
font-size 50
text-anchor middle
text 0.0,90.0 "'butt' cap"
pop graphic-context
pop graphic-context
push graphic-context
translate 600.0,75.0
push graphic-context
stroke "black"
stroke-linecap round
stroke-width 70.0
line -125,0 125,0
pop graphic-context
push graphic-context
stroke "#ffcccc"
stroke-width 5.0
line -125,0 125,0
pop graphic-context
push graphic-context
fill "#ffcccc"
stroke "none"
circle -125,0 -117,0
pop graphic-context
push graphic-context
fill "#ffcccc"
stroke "none"
circle 125,0 133,0
pop graphic-context
push graphic-context
font-family 'Verdana'
font-size 50
text-anchor middle
text 0.0,90.0 "'round' cap"
pop graphic-context
pop graphic-context
push graphic-context
translate 1000.0,75.0
push graphic-context
stroke "black"
stroke-linecap square
stroke-width 70.0
line -125,0 125,0
pop graphic-context
push graphic-context
stroke "#ffcccc"
stroke-width 5.0
line -125,0 125,0
pop graphic-context
push graphic-context
fill "#ffcccc"
stroke "none"
circle -125,0 -117,0
pop graphic-context
push graphic-context
fill "#ffcccc"
stroke "none"
circle 125,0 133,0
pop graphic-context
push graphic-context
font-family 'Verdana'
font-size 50
text-anchor middle
text 0.0,90.0 "'square' cap"
pop graphic-context
pop graphic-context
push graphic-context
fill "none"
stroke "blue"
rectangle 1,1 1193,196
pop graphic-context
pop graphic-context/;
$image = Image::Magick->new(magick=>"MVG",size=>"425x75");
$image->Read(blob=>$blob);
$image->Display();
Re: linecap and linejoin properties in Perl Magick?
Posted: 2007-03-20T17:19:32-07:00
by burgerguy
Cool. Thanks.