From 3002a95bd7015498c78deda78fd56c3ae0f37631 Mon Sep 17 00:00:00 2001 From: Janne Koschinski <janne@kuschku.de> Date: Wed, 20 Jan 2021 18:17:09 +0100 Subject: [PATCH] Modify scaler and add support for color profiles --- main.go | 2 +- util.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index ca9e6ec..2d9f849 100644 --- a/main.go +++ b/main.go @@ -63,7 +63,7 @@ func processImage(config *Config, client *redis.Client, value string) { profiles[name] = wand.GetImageProfile(name) } - err = wandLinear.TransformImageColorspace(imagick.COLORSPACE_RGB) + err = wandLinear.TransformImageColorspace(imagick.COLORSPACE_LAB) if err != nil { panic(err) } diff --git a/util.go b/util.go index d0b6f56..a293423 100644 --- a/util.go +++ b/util.go @@ -69,14 +69,14 @@ func resize(wand *imagick.MagickWand, wandLinear *imagick.MagickWand, originalCo } if (width != nWidth) || (height != nHeight) { - err = mw.ResizeImage(nWidth, nHeight, imagick.FILTER_LANCZOS, 1) + err = mw.ResizeImage(nWidth, nHeight, imagick.FILTER_BOX, 1) if err != nil { return err } } } - err = mw.TransformImageColorspace(imagick.COLORSPACE_SRGB) + err = mw.TransformImageColorspace(originalColorSpace) if err != nil { return err } @@ -91,6 +91,10 @@ func resize(wand *imagick.MagickWand, wandLinear *imagick.MagickWand, originalCo _ = mw.StripImage() + for key, value := range profiles { + _ = mw.SetImageProfile(key, []byte(value)) + } + err = mw.WriteImage(target) return err -- GitLab