I am using the following code in Go to resize my images in JPEG and PNG format. So, how do I convert them to progressive and optimized using Imagick. I'm using ImageMagick 6.9.3-8 Q16 x86_64
on ubuntu 14.04
I am saying optimized reason being I used the following command to test whether image size gets reduced or not. But, it increases the output file size.
Command :
convert -strip -interlace Plane input-file.jpg output-file.jpg
Go code :
size = fmt.Sprintf("%dx%d^+0+0", w, h)
tx := mw.TransformImage("", size)
tx.SetImageGravity(imagick.GRAVITY_CENTER)
offsetX := -(int(w) - int(tx.GetImageWidth())) / 2
offsetY := -(int(h) - int(tx.GetImageHeight())) / 2
err := tx.ExtentImage(w, h, offsetX, offsetY)
Your convert command line strips the image and gives it a planar interlace scheme. An equivalent Go code should call mw.StripImage() and mw.SetImageInterlaceScheme(INTERLACE_PLANE).
[edit] Are you trying to follow this example ? If so, -interlace Plane is responsible for making the image progressive, but this doesn’t make it any smaller. The part that does that is -quality 80, which you can implement in Go by calling mw.SetImageCompressionQuality(80).