Problem with Border #1703
-
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
I don't understand what you are trying to do and what is not going as expected. Can you share both input images and the output image that you want to get? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Impossible? |
Beta Was this translation helpful? Give feedback.
-
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 = new MagickImage(new MagickColor("#FF2200"), firstBorder.Width, firstBorder.Height);
secondBorder.Composite(firstBorder, CompositeOperator.CopyAlpha);
secondBorder.Resize(new MagickGeometry($"{firstBorder.Width + 10}x{firstBorder.Height + 10}!"));
secondBorder.Composite(firstBorder, Gravity.Center, CompositeOperator.Over);
secondBorder.Write("output.png"); |
Beta Was this translation helpful? Give feedback.
-
I was wrong, I apologize. Your solution is what is needed! Thank you! |
Beta Was this translation helpful? Give feedback.
This is probably not the best solution but you could do something like this: