Skip to content

Commit

Permalink
fix identify for calculated format
Browse files Browse the repository at this point in the history
fix #859
  • Loading branch information
SvyatoslavPozhydaev committed Apr 27, 2023
1 parent 6ad6cce commit 8b7af3f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 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 @@ -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);
Expand All @@ -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.
Expand Down

0 comments on commit 8b7af3f

Please sign in to comment.