diff --git a/lib/getters.js b/lib/getters.js index 14bbcf0..2e6efb4 100755 --- a/lib/getters.js +++ b/lib/getters.js @@ -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. @@ -270,6 +276,10 @@ module.exports = function (gm) { 'identify' , '-ping' ]; + + if (!isFormatCalculated(val.format)) { + args.push('-ping') + } if (val.format) { args.push('-format', val.format); @@ -282,6 +292,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.