I want to use ImageMagick to edit an existing image by making some selected points a specific colour.
I am trying to use the Draw command with the ‘point’ primitive. However, I can only get a black point regardless of what colour I am trying to set.
This is shown in the Perl code below where:
1. I draw a blue rectangle;
2. Try and set a number of points to white in a rectangle that partly overlaps the blue rectangle.
However, I get black points in the rectangle.
How can I set white (and any other colour) points?
use Image::Magick;
my ($col, $img_width, $row, $img_height);
# Create a new image
my $im = Image::Magick->new(size => '400x300');
# Give it a white background
$im->Read('xc:white');
# Put a rectangle in there somewhere
$im->Draw(primitive => 'rectangle',
points => '0,129 199,169',
fill => 'blue',
stroke => 'blue');
for($col = 50; $col < 100; $col ++ ) {
for ($row = 150; $row < 200; $row ++ ) {
$im->Draw(primitive => 'point',
points => "$col,$row",
stroke => 'white');
}
}
$im->Write('pointquery.png');
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.