I'd like to rasterize a PDF source (in this case to PNG, 500x500 pixels) using these golang bindings for ImageMagick6. On the CLI, I can do this using
convert -density 5000 -define psd:fit-page=500x test.pdf -resize 500x test.png
which results in a smoothly rendered image.
What I'm failing to do right now is to produce something similar using the API: either the resulting image has scaled pixels or is blurry and has a size 500x500 pixels, or it's in the "original" size.
Here's a minimum snippet of my playground code:
package main
import "gopkg.in/gographics/imagick.v2/imagick"
func main() {
imagick.Initialize()
defer imagick.Terminate()
mw := imagick.NewMagickWand()
defer mw.Destroy()
mw.SetImageResolution(5000,5000)
mw.SetOption("psd:fit-page", "500x")
mw.ReadImage("test.pdf")
mw.ResizeImage(500, 500, imagick.FILTER_POINT, 1)
mw.SetIteratorIndex(0) // This being the page offset
mw.SetImageFormat("png")
mw.WriteImage("test.png")
}
I got confused by density, image size, image resolution and canvas size I guess. How is it meant to be used?