Skip to content

Commit 75b8f17

Browse files
fix identify for calculated format
fix #859
1 parent 6ad6cce commit 75b8f17

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

lib/getters.js

Lines changed: 18 additions & 1 deletion
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.
@@ -268,8 +274,11 @@ module.exports = function (gm) {
268274
function makeArgs (self, val) {
269275
var args = [
270276
'identify'
271-
, '-ping'
272277
];
278+
279+
if (!isFormatCalculated(val.format)) {
280+
args.push('-ping')
281+
}
273282

274283
if (val.format) {
275284
args.push('-format', val.format);
@@ -282,6 +291,14 @@ module.exports = function (gm) {
282291
args = args.concat(self.src());
283292
return args;
284293
}
294+
295+
/**
296+
* @param {string|undefined} format
297+
* @returns {boolean}
298+
*/
299+
function isFormatCalculated(format) {
300+
return !format || !!CALCULATED_FORMATS.test(format);
301+
}
285302

286303
/**
287304
* Map exif orientation codes to orientation names.

0 commit comments

Comments
 (0)