From 11866e6c5ac7a9b0557fde52b5904502301f0db0 Mon Sep 17 00:00:00 2001 From: Leon Weidauer Date: Thu, 8 Oct 2015 18:03:45 +0200 Subject: [PATCH] added switch for preferred AOI. #122 --- README.md | 2 ++ config/default.yml | 1 + lib/processing.js | 7 ++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a3b9e8..c1edb54 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,8 @@ By default images are cropped from the center of the original. You can specify a The AOI can also be embedded in the original image's metadata via EXIF or IPTC. The name of this metadata field can be configured and defaults to `aoi`. The request parameter overrides the AOI value from the image's metadata. +By default, the AOI in the URL parameters has precedence over the one from the image's metadata. To prefer the embedded AOI from the metadata, set the `prefer_embedded_aoi` parameter to any non-emty value. + ### Cropping mode The `crop` parameter sets the cropping mode. Available modes are: diff --git a/config/default.yml b/config/default.yml index 9e78152..e6098d2 100644 --- a/config/default.yml +++ b/config/default.yml @@ -36,6 +36,7 @@ converter: cropping: default_mode: "aoi_coverage" + prefer_embedded_aoi: false constraints: quality: diff --git a/lib/processing.js b/lib/processing.js index 85f8c8e..f19cbe7 100644 --- a/lib/processing.js +++ b/lib/processing.js @@ -14,6 +14,7 @@ function set_default_options(item) { options.format = options.format || analysis.format; options.crop = options.crop || item.conf.cropping.default_mode; + options.prefer_embedded_aoi = options.prefer_embedded_aoi || item.conf.prefer_embedded_aoi; options.strip_metadata = (typeof options.strip_metadata !== "undefined"); //ensure this is a boolean } @@ -31,6 +32,10 @@ function extract_preset_data(item) { } function create_aoi(w, h, aoi) { + if (!aoi) { + return; + } + var parts = aoi.split(","); if (parts.length !== 4) { throw new AoiFormatError(aoi); @@ -74,7 +79,7 @@ function add_cropping(item) { var crop; var aoi; - if (typeof options.aoi !== "undefined") { + if (typeof options.aoi !== "undefined" && !options.prefer_embedded_aoi) { aoi = create_aoi(analysis.width, analysis.height, options.aoi); } else { aoi = create_aoi(analysis.width, analysis.height, analysis.aoi);