Skip to content

Commit 65da67d

Browse files
fix identify for calculated format
fix #859
1 parent 6ad6cce commit 65da67d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

lib/getters.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ module.exports = function (gm) {
1212

1313
const IDENTIFYING = 1;
1414
const IDENTIFIED = 2;
15+
16+
/**
17+
* calculated formats https://imagemagick.org/script/escape.php
18+
* @type {RegExp}
19+
*/
20+
const CALCULATED_FORMATS = /%k|%@|%#/
1521

1622
/**
1723
* Map getter functions to output names.
@@ -270,6 +276,10 @@ module.exports = function (gm) {
270276
'identify'
271277
, '-ping'
272278
];
279+
280+
if (!isFormatCalculated(val.format)) {
281+
args.push('-ping')
282+
}
273283

274284
if (val.format) {
275285
args.push('-format', val.format);
@@ -282,6 +292,14 @@ module.exports = function (gm) {
282292
args = args.concat(self.src());
283293
return args;
284294
}
295+
296+
/**
297+
* @param {string|undefined} format
298+
* @returns {boolean}
299+
*/
300+
function isFormatCalculated(format) {
301+
return !format || !!CALCULATED_FORMATS.test(format);
302+
}
285303

286304
/**
287305
* Map exif orientation codes to orientation names.

0 commit comments

Comments
 (0)