From adae2a9a7f18f7c33450cf97b3436ce43fd85bd4 Mon Sep 17 00:00:00 2001 From: erulabs Date: Wed, 26 Oct 2016 14:50:51 -0700 Subject: [PATCH 1/3] update go and swap to graphicsmagic --- Dockerfile | 4 ++-- imageprocessor/processorcommand/gm.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d5b73f4..66caa97 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -FROM golang:1.5 -RUN apt-get update && apt-get install -yqq aspell aspell-en libaspell-dev tesseract-ocr tesseract-ocr-eng imagemagick optipng exiftool libjpeg-progs webp +FROM golang:1.8 +RUN apt-get update && apt-get install -yqq aspell aspell-en libaspell-dev tesseract-ocr tesseract-ocr-eng graphicsmagick optipng exiftool libjpeg-progs webp ADD docker/meme.traineddata /usr/share/tesseract-ocr/tessdata/meme.traineddata ADD docker/imagemagick_policy.xml /etc/ImageMagick-6/policy.xml RUN mkdir -p /etc/mandible /tmp/imagestore diff --git a/imageprocessor/processorcommand/gm.go b/imageprocessor/processorcommand/gm.go index c8211f0..72c21e4 100644 --- a/imageprocessor/processorcommand/gm.go +++ b/imageprocessor/processorcommand/gm.go @@ -6,7 +6,7 @@ import ( "github.com/Imgur/mandible/imageprocessor/thumbType" ) -const GM_COMMAND = "convert" +const GM_COMMAND = "gm convert" func ConvertToJpeg(filename string) (string, error) { outfile := fmt.Sprintf("%s_jpg", filename) From 82d5a142af7bfcb4fd4fc7ea96584a2e88d8b814 Mon Sep 17 00:00:00 2001 From: erulabs Date: Wed, 26 Oct 2016 14:56:10 -0700 Subject: [PATCH 2/3] back down to go 1.7, cleanup imagicpolicy and GO15VENDOREXPERIMENT --- Dockerfile | 4 +-- docker/imagemagick_policy.xml | 56 ----------------------------------- 2 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 docker/imagemagick_policy.xml diff --git a/Dockerfile b/Dockerfile index 66caa97..d179297 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,8 @@ -FROM golang:1.8 +FROM golang:1.7 RUN apt-get update && apt-get install -yqq aspell aspell-en libaspell-dev tesseract-ocr tesseract-ocr-eng graphicsmagick optipng exiftool libjpeg-progs webp ADD docker/meme.traineddata /usr/share/tesseract-ocr/tessdata/meme.traineddata -ADD docker/imagemagick_policy.xml /etc/ImageMagick-6/policy.xml RUN mkdir -p /etc/mandible /tmp/imagestore ENV MANDIBLE_CONF /etc/mandible/conf.json -ENV GO15VENDOREXPERIMENT 1 ADD . /go/src/github.com/Imgur/mandible WORKDIR /go/src/github.com/Imgur/mandible RUN go get github.com/mattn/goveralls diff --git a/docker/imagemagick_policy.xml b/docker/imagemagick_policy.xml deleted file mode 100644 index 2007515..0000000 --- a/docker/imagemagick_policy.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - -]> - - - - - - - - - - - - - - From 793a5574be0e231092bbe0cba2b7f2f1adeffc00 Mon Sep 17 00:00:00 2001 From: erulabs Date: Wed, 26 Oct 2016 15:42:21 -0700 Subject: [PATCH 3/3] swap 'convert' into args --- imageprocessor/processorcommand/gm.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/imageprocessor/processorcommand/gm.go b/imageprocessor/processorcommand/gm.go index 72c21e4..9453838 100644 --- a/imageprocessor/processorcommand/gm.go +++ b/imageprocessor/processorcommand/gm.go @@ -6,12 +6,13 @@ import ( "github.com/Imgur/mandible/imageprocessor/thumbType" ) -const GM_COMMAND = "gm convert" +const GM_COMMAND = "gm" func ConvertToJpeg(filename string) (string, error) { outfile := fmt.Sprintf("%s_jpg", filename) args := []string{ + "convert", filename, "-flatten", "JPEG:" + outfile, @@ -29,6 +30,7 @@ func FixOrientation(filename string) (string, error) { outfile := fmt.Sprintf("%s_ort", filename) args := []string{ + "convert", filename, "-auto-orient", outfile, @@ -46,6 +48,7 @@ func Quality(filename string, quality int) (string, error) { outfile := fmt.Sprintf("%s_q", filename) args := []string{ + "convert", filename, "-quality", fmt.Sprintf("%d", quality), @@ -66,6 +69,7 @@ func ResizePercent(filename string, percent int) (string, error) { outfile := fmt.Sprintf("%s_rp", filename) args := []string{ + "convert", filename, "-resize", fmt.Sprintf("%d%%", percent), @@ -84,6 +88,7 @@ func SquareThumb(filename, name string, size int, quality int, format thumbType. outfile := fmt.Sprintf("%s_%s", filename, name) args := []string{ + "convert", fmt.Sprintf("%s[0]", filename), "-resize", fmt.Sprintf("%dx%d^", size, size), @@ -118,6 +123,7 @@ func Thumb(filename, name string, width, height int, quality int, format thumbTy outfile := fmt.Sprintf("%s_%s", filename, name) args := []string{ + "convert", fmt.Sprintf("%s[0]", filename), "-resize", fmt.Sprintf("%dx%d>", width, height), @@ -151,6 +157,7 @@ func CircleThumb(filename, name string, width int, quality int, format thumbType } args := []string{ + "convert", "-size", fmt.Sprintf("%dx%d", width, width), "xc:none", @@ -185,6 +192,7 @@ func CustomThumb(filename, name string, width, height int, cropGravity string, c outfile := fmt.Sprintf("%s_%s", filename, name) args := []string{ + "convert", fmt.Sprintf("%s[0]", filename), "-resize", fmt.Sprintf("%dx%d^", width, height), @@ -221,6 +229,7 @@ func Full(filename string, name string, quality int, format thumbType.ThumbType) outfile := fmt.Sprintf("%s_%s", filename, name) args := []string{ + "convert", fmt.Sprintf("%s[0]", filename), "-density", "72x72",