Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ module.exports = function (gm) {

const IDENTIFYING = 1;
const IDENTIFIED = 2;

/**
* calculated formats https://imagemagick.org/script/escape.php
* @type {RegExp}
*/
const CALCULATED_FORMATS = /%k|%@|%#/

/**
* Map getter functions to output names.
Expand Down Expand Up @@ -268,8 +274,11 @@ module.exports = function (gm) {
function makeArgs (self, val) {
var args = [
'identify'
, '-ping'
];

if (!isFormatCalculated(val.format)) {
args.push('-ping')
}

if (val.format) {
args.push('-format', val.format);
Expand All @@ -282,6 +291,14 @@ module.exports = function (gm) {
args = args.concat(self.src());
return args;
}

/**
* @param {string|undefined} format
* @returns {boolean}
*/
function isFormatCalculated(format) {
return !format || !!CALCULATED_FORMATS.test(format);
}

/**
* Map exif orientation codes to orientation names.
Expand Down