How can I rotate transparent png 45 degrees using imagemagick and keep the new image transparent?

I have transparent png 16x16 and I made

convert -rotate -45 a.png b.png

This rotated it and created a new b.png image with a size of 22x22 and which, when I use the background, shows the original image (16x16) rotated with the base background, but a new fill appears with a white background.

How is it possible for a new fill to be transparent?

If this is not possible, then how can I create the entire background image of a new image in one color?

+5
source share
5 answers

-background, - :

convert -background 'rgba(0,0,0,0)' -rotate 45 a.png b.png

+7

:

  -background none
+5

I also had the same problem, however I used the command like this:

convert a.png -rotate 45 -background transparent b.png

It should be:

convert -rotate 45 -background transparent a.png b.png

So it really helped a little, thanks :)

0
source
convert -rotate 66 -background none c:\input.png c:\output.png

works well for me

0
source

I used C # to rotate it

using (MagickImage mimg = new MagickImage(path))
{
  mimg.BackgroundColor = MagickColor.Transparent;
  mimg.Alpha(AlphaOption.Background);
  mimg.AlphaColor = new MagickColor(System.Drawing.Color.White);
  mimg.FillColor = new MagickColor(255, 255, 255, 0);
  mimg.Rotate(degree);                    
}
0
source

All Articles