Reputation: 322
I am trying to use the perspective feature of ImageMagick. I've looked at the examples and I can't understand what values correspond to. I have this code:
var stream = new MemoryStream();
using (MagickImage image = new MagickImage("image.jpg"))
{
image.VirtualPixelMethod = VirtualPixelMethod.Tile;
image.MatteColor = Color.DodgerBlue;
image.Distort(DistortMethod.Perspective, new double[] { 0, 0, 20, 60, 90, 0, 70, 63, 0, 90, 5, 83, 90, 90, 85, 88 });
image.Write(stream);
}
And I have this image:
outputs:
What I really want is to be able to change the perspective and size similar and get it to look similar to this:
It might not be as high quality, but I would like to see similar results. How can I achieve this?
Upvotes: 2
Views: 1324
Reputation: 594
The string of numbers are coordinates identifying which pixels to move and to where. In your example, the first two numbers 0, 0
identify the pixel in the top,left corner. The next pair of numbers 20, 60
indicate the destination of that pixel after the distortion. The next pair 90, 0
identify the next pixel to move, followed by the coordinates of its destination. The software figures out what to do with all the pixels in between.
Your four pairs of coordinates are four corners of a box: where they are and where you want them to be.
There are some good examples on the ImageMagick Usage site.
Upvotes: 3