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

New Post: Squaring an image

$
0
0
I need help converting a command that that will convert the image proportions to a square, that is, equal width and height without distorting the image, and fill the background with white. Here is my old code:

convert.exe "C:\input_rectangle.jpg" -virtual-pixel background -background white -set option:distort:viewport "%[fx:max(w,h)]x%[fx:max(w,h)]-%[fx:max((h-w)/2,0)]-%[fx:max((w-h)/2,0)]" -filter point -distort SRT 0 +repage "C:\output_square.jpg"

This is as far as I got, but it doesn't work:
            image.VirtualPixelMethod = VirtualPixelMethod.Background;
            image.BackgroundColor = new MagickColor(System.Drawing.Color.White);
            image.SetArtifact("option:distort:viewport", "%[fx:max(w,h)]x%[fx:max(w,h)]-%[fx:max((h-w)/2,0)]-%[fx:max((w-h)/2,0)]");

            image.FilterType = FilterType.Point;

            image.Distort(DistortMethod.ScaleRotateTranslate, new double[] { 0 });
            image.RePage();
Thanks in advance!

Viewing all articles
Browse latest Browse all 3693

Trending Articles



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