Exemple #1
0
// Shrink an image so that its longest dimension is no longer than maxSize
func shrinkImage(wand *imagick.MagickWand, maxSize int) (w, h uint) {

	w, h = getDimensions(wand)

	shrinkBy := 1

	if w >= h {
		shrinkBy = int(w) / maxSize
	} else {
		shrinkBy = int(h) / maxSize
	}

	wand.AdaptiveResizeImage(
		uint(int(w)/shrinkBy),
		uint(int(h)/shrinkBy),
	)

	// Sharpen the image to bring back some of the color lost in the shrinking
	wand.AdaptiveSharpenImage(0, AdaptiveSharpenVal)

	w, h = getDimensions(wand)

	return
}