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:
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!