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

New Post: trying to convert a command line to VB, getting close but cant get gravity to work

$
0
0
Using VB.NET 2010, I am trying to resize a image to be 96x72, the image itself will be xx X 72 when resized and I want to center it in a colored box. The convert command line is

convert test.jpg -quality 85 -thumbnail 96x72">" -background antiquewhite3 -gravity center -extent 96x72 test2.jpg

I am getting close with .NET but the image is sticking to the left of the image and I can't seem to CENTER it, I have tried a variety of things and I am close, but I need to center the image.
    Using image As New MagickImage("C:\Users\User\Desktop\test\newImageMagick\test.jpg")

        '-quality 85 -thumbnail 96x72">"  -background antiquewhite3 -gravity center -extent 96x72 
        image.Quality = 85

        'Create thumnail that is 96 pixels wide and 72 pixels high
        image.Thumbnail(96, 72)

        'since the test image ends up being 54x72 (in this case), now we want to make it 96x72 with the image in the center and a background border of antique white on both sides.
        'set the background
        image.BackgroundColor = ImageMagick.MagickColors.AntiqueWhite

        'image.Settings.SetDefine(MagickFormat.Jpeg, "-gravity", "center") 'didn't work.
        image.Composite(image, ImageMagick.Gravity.Center) 'tried a variety of  CompositeOperators)

        image.Extent(96, 72)

        ' Save the result
        image.Write("C:\Users\User\Desktop\test\newImageMagick\test.thumb.jpg")
    End Using

Viewing all articles
Browse latest Browse all 3693

Trending Articles



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