diff --git a/main.go b/main.go
index dd51d1eae41e875fee4a5e27b553c65c26929e52..3e4df0892e2a9bf869c11877ff6171f0943c64f3 100644
--- a/main.go
+++ b/main.go
@@ -1,14 +1,14 @@
 package main
 
 import (
-	"github.com/go-redis/redis"
 	"encoding/json"
-	"os"
-	"gopkg.in/gographics/imagick.v2/imagick"
 	"fmt"
+	"github.com/go-redis/redis"
+	"gopkg.in/gographics/imagick.v2/imagick"
+	"net/http"
+	"os"
 	"path/filepath"
 	"time"
-	"net/http"
 )
 
 func returnResult(config *Config, client *redis.Client, result Result) {
@@ -19,10 +19,11 @@ func returnResult(config *Config, client *redis.Client, result Result) {
 	client.Publish(config.ResultChannel, string(raw))
 }
 
-func generateSize(errorChannel chan error, wand *imagick.MagickWand, wandLinear *imagick.MagickWand, config *Config, image Image, definition SizeDefinition) {
+func generateSize(errorChannel chan error, wand *imagick.MagickWand, wandLinear *imagick.MagickWand, colorSpace imagick.ColorspaceType, config *Config, image Image, definition SizeDefinition) {
 	errorChannel <- resize(
 		wand,
 		wandLinear,
+		colorSpace,
 		definition.Size,
 		config.Quality,
 		filepath.Join(config.TargetFolder, fmt.Sprintf("%s%s", image.Id, definition.Suffix)),
@@ -49,13 +50,19 @@ func processImage(config *Config, client *redis.Client, value string) {
 	wandLinear := wand.Clone()
 	defer wandLinear.Destroy()
 
+	colorSpace := wand.GetImageColorspace()
+	if colorSpace == imagick.COLORSPACE_UNDEFINED {
+		colorSpace = imagick.COLORSPACE_SRGB
+	}
+	println(colorSpaceName(colorSpace))
+
 	err = wandLinear.TransformImageColorspace(imagick.COLORSPACE_RGB)
 	if err != nil {
 		panic(err)
 	}
 
 	for _, definition := range config.Sizes {
-		go generateSize(errorChannel, wand, wandLinear, config, image, definition)
+		go generateSize(errorChannel, wand, wandLinear, colorSpace, config, image, definition)
 	}
 
 	errors := make([]string, 0)
diff --git a/util.go b/util.go
index 86950c97063e55536b15cc3b6fe36fa3bf21c935..d8939c7ad963ca4ff52f45b36b507741093da9b6 100644
--- a/util.go
+++ b/util.go
@@ -59,29 +59,17 @@ func colorSpaceName(colorSpace imagick.ColorspaceType) string {
 	}
 }
 
-func resize(wand *imagick.MagickWand, wandLinear *imagick.MagickWand, size Size, quality Quality, target string) error {
+func resize(wand *imagick.MagickWand, wandLinear *imagick.MagickWand, originalColorSpace imagick.ColorspaceType, size Size, quality Quality, target string) error {
 	var err error
 	var mw *imagick.MagickWand
 
-	var colorSpace imagick.ColorspaceType
-
 	if size.Width == 0 && size.Height == 0 {
 		mw = wand.Clone()
 		defer mw.Destroy()
-
-		colorSpace = mw.GetImageColorspace()
-		if colorSpace == imagick.COLORSPACE_UNDEFINED {
-			colorSpace = imagick.COLORSPACE_SRGB
-		}
 	} else {
 		mw = wandLinear.Clone()
 		defer mw.Destroy()
 
-		colorSpace = mw.GetImageColorspace()
-		if colorSpace == imagick.COLORSPACE_UNDEFINED {
-			colorSpace = imagick.COLORSPACE_SRGB
-		}
-
 		width := mw.GetImageWidth()
 		height := mw.GetImageHeight()
 
@@ -138,7 +126,7 @@ func resize(wand *imagick.MagickWand, wandLinear *imagick.MagickWand, size Size,
 				return err
 			}
 
-			err = mw.TransformImageColorspace(colorSpace)
+			err = mw.TransformImageColorspace(originalColorSpace)
 			if err != nil {
 				return err
 			}
@@ -163,7 +151,6 @@ func resize(wand *imagick.MagickWand, wandLinear *imagick.MagickWand, size Size,
 		mw.SetImageProfile("IPTC", []byte(iptcProfile))
 	}
 
-	println(colorSpaceName(colorSpace))
 	err = mw.WriteImage(target)
 
 	return err