My own project produces core dumps (which is how I discovered the trouble), though in trying to write a smaller demo I didn't get core dumps, just weirdness. But that's enough.
I hope I don't make this sound more complicated than it is; a simple standalone script is at the end.
There are two images at the Imgur link below -- one before MogrifyImage is called and one after. I know they're a bit too psychedelic, but I wanted to see where the shards were flying off to, and this helped. Check out the "after" image, in which nine (pairs of) calls to MogrifyImage are made atop the "before" image, each pair being identical except for the first arguments, the region geometry. The "circle" part looks like so, for example:
Code: Select all
$image->MogrifyRegion("120x120-45+325", "draw", primitive=>"circle", points=>"60,60 0,60", fill=> ...
(The actual images here are 400x400. Notice that the above snippet tries to plant a black disk of radius 60 at the center of a 120x120 region.) Each pair of calls should draw an identical diamond atop a circle, except that 8 of them (all but the center one) go partially out of bounds (in symmetric fashion). The ones with positive out-of-bound-ness do fine (or seem to, but who knows what lurks within) -- these are the four diamond/disk figures in the lower right of the image (Center, E, SE, and S, if you like, though I'm not invoking any gravity). The center circle-diamond figure shows the whole thing, the E, SE, and S chunks are "drawn" the same way, but the region code seems to handle it. The remaining four (W, NW, N, NE) each stray into negative territory and these go way wrong, as you can see (on Imgur):
https://imgur.com/a/6CNCq
There is no Region method in PerlMagick, nor can one Set(region=>...), so MogrifyRegion seems like a workaround, but it is quite handy. In particular, you can actually Draw within the region as one would like, as opposed to what I mentioned recently, in a post titled "-region -draw". It would be nice to see it fixed. As a workaround I can add code to my project to avoid core dumping, but that's untidy.
Here's a small standalone script that shows the problem well enough. The two "shards" of circles that result in this case belong to the west and north pieces; there's a clue in there somewhere. If you move those two calls before the east and south you get no shards, but the error is still obvious.
Code: Select all
use Image::Magick;
$image = new Image::Magick;
$image->Set(size=>"200x200");
$image->ReadImage('xc:#888888');
# South:
$image->MogrifyRegion("100x100+50+125", 'draw',
fill=>"blue", primitive=>"circle", points=>"50,50 50,10");
# East:
$image->MogrifyRegion("100x100+125+50", 'draw',
fill=>"red", primitive=>"circle", points=>"50,50 50,10");
# North:
$image->MogrifyRegion("100x100+50-25", 'draw',
fill=>"green", primitive=>"circle", points=>"50,50 50,10");
# West:
$image->MogrifyRegion("100x100-25+50", 'draw',
fill=>"black", primitive=>"circle", points=>"50,50 50,10");
$image->Write("mogrifyRegion-some.png");