From cb104acee998faec64ef9710a9dbd0a11bea8f37 Mon Sep 17 00:00:00 2001 From: Justin Israel Date: Sat, 9 Sep 2023 16:31:00 +1200 Subject: [PATCH] Add MagickAutoThresholdImage; bump min im7 to 7.0.8-41 (refs #295) --- Dockerfile | 2 +- README.md | 6 +++--- imagick/magick_wand_image.go | 11 +++++++++++ imagick/threshold_type.go | 19 +++++++++++++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 imagick/threshold_type.go diff --git a/Dockerfile b/Dockerfile index 152df24..ce866df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* ARG IMAGEMAGICK_PROJECT=ImageMagick -ARG IMAGEMAGICK_VERSION=7.0.8-11 +ARG IMAGEMAGICK_VERSION=7.0.8-41 ENV IMAGEMAGICK_VERSION=$IMAGEMAGICK_VERSION RUN cd && \ diff --git a/README.md b/README.md index 0776505..faf14ed 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ Go Imagick is a Go bind to ImageMagick's MagickWand C API. We support two compatibility branches: ``` -im-7 (tag v3.x.x): 7.x <= ImageMagick <= 7.x -master (tag v2.x.x): 6.9.1-7 <= ImageMagick <= 6.9.9-35 -legacy (tag v1.x.x): 6.7.x <= ImageMagick <= 6.8.9-10 +im-7 (tag v3.x.x): 7.0.8-41 <= ImageMagick <= 7.x +master (tag v2.x.x): 6.9.1-7 <= ImageMagick <= 6.9.9-35 +legacy (tag v1.x.x): 6.7.x <= ImageMagick <= 6.8.9-10 ``` They map, respectively, through gopkg.in: diff --git a/imagick/magick_wand_image.go b/imagick/magick_wand_image.go index 2396287..0a53a2c 100644 --- a/imagick/magick_wand_image.go +++ b/imagick/magick_wand_image.go @@ -2413,6 +2413,17 @@ func (mw *MagickWand) AutoOrientImage() error { return mw.getLastErrorIfFailed(ok) } +// AutoThresholdImage automatically performs image thresholding +// dependent on which method you specify. +// +// A description of each parameter follows: +// +// method: choose from Kapur, OTSU, or Triangle. +func (mw *MagickWand) AutoThresholdImage(method AutoThresholdMethodType) error { + ok := C.MagickAutoThresholdImage(mw.mw, C.AutoThresholdMethod(method)) + return mw.getLastErrorIfFailed(ok) +} + // Sets the page geometry of the image. func (mw *MagickWand) SetImagePage(width, height uint, x, y int) error { ok := C.MagickSetImagePage(mw.mw, C.size_t(width), C.size_t(height), C.ssize_t(x), C.ssize_t(y)) diff --git a/imagick/threshold_type.go b/imagick/threshold_type.go new file mode 100644 index 0000000..043979e --- /dev/null +++ b/imagick/threshold_type.go @@ -0,0 +1,19 @@ +// Copyright 2013 Herbert G. Fischer. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package imagick + +/* +#include +*/ +import "C" + +type AutoThresholdMethodType int + +const ( + AUTO_THRESHOLD_METHOD_UNDEFINED AutoThresholdMethodType = C.UndefinedThresholdMethod + AUTO_THRESHOLD_METHOD_KAPUR AutoThresholdMethodType = C.KapurThresholdMethod + AUTO_THRESHOLD_METHOD_OTSU AutoThresholdMethodType = C.OTSUThresholdMethod + AUTO_THRESHOLD_METHOD_TRIANGLE AutoThresholdMethodType = C.TriangleThresholdMethod +)