Skip to content

Commit

Permalink
Fixes #273
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jan 15, 2025
1 parent d262378 commit 8bb0f5b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class Image {
debug("Filtering non-animated formats from output: from %o to %o", formats, validAnimatedFormats);
formats = validAnimatedFormats;
} else {
debug("No animated output formats found for animated image, using static image instead.");
debug("No animated output formats found for animated image, using original formats (may be a static image): %o", formats);
}
}

Expand All @@ -254,7 +254,7 @@ class Image {
debug("Filtering non-transparency-friendly formats from output: from %o to %o", formats, validTransparencyFormats);
formats = validTransparencyFormats;
} else {
debug("At least one transparency-friendly output format of %o must be included if the source image has an alpha channel, skipping formatFiltering and using original formats.", MINIMUM_TRANSPARENCY_TYPES);
debug("At least one transparency-friendly output format of %o must be included if the source image has an alpha channel, skipping formatFiltering and using original formats: %o", MINIMUM_TRANSPARENCY_TYPES, formats);
}
}

Expand Down Expand Up @@ -499,8 +499,19 @@ class Image {
return false;
}

// input has multiple pages: https://sharp.pixelplumbing.com/api-input#metadata
return metadata?.pages > 1;
let isAnimationFriendlyFormat = ANIMATED_TYPES.includes(metadata.format);
if(!isAnimationFriendlyFormat) {
return false;
}

if(metadata?.pages) {
// input has multiple pages: https://sharp.pixelplumbing.com/api-input#metadata
// this is *unknown* when not called from `resize` (limited metadata available)
return metadata?.pages > 1;
}

// Best guess
return isAnimationFriendlyFormat;
}

getEntryFormat(metadata) {
Expand Down

0 comments on commit 8bb0f5b

Please sign in to comment.