Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
added switch for preferred AOI. #122
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon Weidauer committed Oct 8, 2015
1 parent 141dba2 commit 11866e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ converter:

cropping:
default_mode: "aoi_coverage"
prefer_embedded_aoi: false

constraints:
quality:
Expand Down
7 changes: 6 additions & 1 deletion lib/processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 11866e6

Please sign in to comment.