I want to fill the black area in the figure below with an image. How can I do it? If not, can I fill it with color #1017
Unanswered
jueqing1015
asked this question in
Help
Replies: 1 comment 11 replies
-
This might now work for every image but you could do something like this: using (var image = new MagickImage("input.jpg"))
{
// Add a border on all sides of the image to make it possible to fill the image.
image.Extent(image.Width + 2, image.Height + 2, Gravity.Center, MagickColors.Black);
// Fill the black border pixels with a transparent color.
image.ColorFuzz = new Percentage(10);
image.FloodFill(MagickColors.Transparent, 0, 0);
// Trim the image to remove the border that was added.
image.Trim();
// Load background image, use your own background instead of the sample below
using (var background = new MagickImage("plasma:", image.Width, image.Height))
{
// Draw background under the image.
image.Composite(background, CompositeOperator.DstAtop);
}
image.Write("output.jpg");
} |
Beta Was this translation helpful? Give feedback.
11 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to fill the black area around the figure above with an image. If it cannot be filled with an image, can I fill it with white,
Beta Was this translation helpful? Give feedback.
All reactions