Reputation: 575
I am trying to overlay 100X100 image on blank 1080X1320 image by repetition.
$ThumbImg = 'thumb_100x100.png';
$new_image = "new.png";
exec("convert -size 1080x1320! xc:transparent all_images/" . $new_image);
$new_image_path = 'all_images/' . $new_image;
// main image width=1080 ,height = 1320,
// thumb image width = 100 , height = 100,
// row=1320/100=14
// col=1080/100=11
for ($row = 0; $row < 14; $row++)
{
for ($col = 0; $col < 11; $col++)
{
exec('composite -geometry +' . ($col * 100) . '+' . ($row * 100) . ' ' . $ThumbImg . ' ' . $new_image_path . ' ' . $new_image_path);
}
}
When i use above code on version 6.9 it works fine and 100x100 image gets repeated uniformly over blank 1080x1320 image. But this doesn't work on 7.0.3 version (latest IM version).
what change would be needed in exec
command to make this work on newer version?
UPDATE -
Solution suggested by mark-setchell
is working for some patterns but for following it doesn't create an image but instead only blank image is created.
UPDATE -
We need to use -set colorspace RGB
in command to get the right result. So command would be
exec('convert new.png -fill thumb.png -set colorspace RGB -draw "color 0,0 reset" result.png');
Upvotes: 0
Views: 354
Reputation: 208052
I think it would be simpler to just use ImageMagick's -fill
operator to tile your 100x100 image over a background.
So, if we create a 100x100 tile to repeat like this:
convert -size 100x100 gradient:cyan-magenta tile.png
Then you can tile that all over a 1080x1320 background like this:
convert xc:black"[1080x1320]" -fill tile.png -draw "color 0,0 reset" result.png
If you want to generate the tile pattern "on-the-fly" in one command, you can do it like this using an MPR (Magick Pixel Register) in memory to hold the fill:
convert -size 100x100 gradient:cyan-magenta -write MPR:tile +delete \
xc:black"[1080x1320]" -fill MPR:tile -draw "color 0,0 reset" result.png
If you wish to continue to use the original composite
command, you need to re-order the parameters as follows with IM v7:
composite new.png -geometry +400+900 tile.png result.png
Upvotes: 1