Skip to content
Snippets Groups Projects
Commit 29d0648e authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Improved imagick error

parent 6dd37c08
Branches
No related tags found
Loading
...@@ -39,7 +39,6 @@ func processImage(config *Config, client *redis.Client, value string) { ...@@ -39,7 +39,6 @@ func processImage(config *Config, client *redis.Client, value string) {
errorChannel := make(chan error) errorChannel := make(chan error)
wand := imagick.NewMagickWand() wand := imagick.NewMagickWand()
defer wand.Destroy()
err := wand.ReadImage(filepath.Join(config.SourceFolder, image.Id)) err := wand.ReadImage(filepath.Join(config.SourceFolder, image.Id))
if err != nil { if err != nil {
...@@ -47,7 +46,6 @@ func processImage(config *Config, client *redis.Client, value string) { ...@@ -47,7 +46,6 @@ func processImage(config *Config, client *redis.Client, value string) {
} }
wandLinear := wand.Clone() wandLinear := wand.Clone()
defer wand.Clear()
err = wandLinear.TransformImageColorspace(imagick.COLORSPACE_RGB) err = wandLinear.TransformImageColorspace(imagick.COLORSPACE_RGB)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -81,6 +79,9 @@ func processImage(config *Config, client *redis.Client, value string) { ...@@ -81,6 +79,9 @@ func processImage(config *Config, client *redis.Client, value string) {
Success: true, Success: true,
}) })
} }
wand.Clear()
wandLinear.Clear()
} }
func main() { func main() {
......
...@@ -10,7 +10,6 @@ import ( ...@@ -10,7 +10,6 @@ import (
func resize(wand *imagick.MagickWand, wandLinear *imagick.MagickWand, size Size, quality Quality, target string) error { func resize(wand *imagick.MagickWand, wandLinear *imagick.MagickWand, size Size, quality Quality, target string) error {
var err error var err error
var mw *imagick.MagickWand var mw *imagick.MagickWand
defer mw.Clear()
if size.Width == 0 && size.Height == 0 { if size.Width == 0 && size.Height == 0 {
mw = wand.Clone() mw = wand.Clone()
...@@ -91,5 +90,8 @@ func resize(wand *imagick.MagickWand, wandLinear *imagick.MagickWand, size Size, ...@@ -91,5 +90,8 @@ func resize(wand *imagick.MagickWand, wandLinear *imagick.MagickWand, size Size,
mw.StripImage() mw.StripImage()
err = mw.WriteImage(target) err = mw.WriteImage(target)
mw.Clear()
return err return err
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment