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

Improved imagick error

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