Skip to content

Problem with Border #1703

Answered by dlemstra
jaka1-newbie asked this question in Help
Aug 27, 2024 · 5 comments · 3 replies
Discussion options

You must be logged in to vote

This is probably not the best solution but you could do something like this:

using var image = new MagickImage("input.png");

using var firstBorder = new MagickImage(new MagickColor("#FFD700"), image.Width, image.Height);
// This copies the alpha channel from the image to the firstBorder
firstBorder.Composite(image, CompositeOperator.CopyAlpha);
// This resizes the firstBorder to the size of the image + 10 pixels on each side and ignores the aspect ratio
firstBorder.Resize(new MagickGeometry($"{image.Width + 10}x{image.Height + 10}!"));
// This composites the image over the firstBorder at the center
firstBorder.Composite(image, Gravity.Center, CompositeOperator.Over);

using var secondBorder

Replies: 5 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@dlemstra
Comment options

Comment options

You must be logged in to vote
2 replies
@jaka1-newbie
Comment options

@dlemstra
Comment options

Answer selected by jaka1-newbie
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants