Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: How can Rotate image without losing the size and alignment

$
0
0
When you rotate an image it will resize the image to make sure the rotated image fits inside the frame. Because you rotate the image multiple times it will become larger and larger. The following demonstrates what is happening:
using (MagickImage image = new MagickImage("logo:"))
{
  image.BackgroundColor = new MagickColor("purple");
  image.Rotate(50);
  image.BackgroundColor = new MagickColor("yellow");
  image.Rotate(50);
  image.Write(@"C:\logo1.png");
}
You will get a better result if you do the whole rotation at once:
using (MagickImage image = new MagickImage("logo:"))
{
  image.BackgroundColor = new MagickColor("purple");
  image.Rotate(100);
  image.Write(@"C:\logo2.png");
}
Or you could trim the image at the end:
using (MagickImage image = new MagickImage("logo:"))
{
  image.BackgroundColor = new MagickColor("purple");
  image.Rotate(50);
  image.Rotate(50);
  image.Trim();
  image.Write(@"C:\logo3.png");
}

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>