vseventer / sharp-cli

CLI for sharp.
MIT License
189 stars 20 forks source link

Unexpected error for any CPU effort outside of the 0...6 range #92

Open marijo-macet opened 2 months ago

marijo-macet commented 2 months ago

CPU effort is one of the output options (--effort) for the PNG, WebP, GIF, AVIF, HEIF and JPEG XL image file formats. According to Sharp's API documentation, the following values are allowed:

But the CLI for Sharp throws an unexpected error for any CPU effort outside of the 0...6 range.

Example:

sharp -i "image.jpg" -o "image.avif" --effort 9 -f "avif"

Expected result:

The input file is converted from JPEG to AVIF with a CPU effort of 9.

Actual result:

An InvalidParameterError is thrown. Error message: "Expected integer between 0 and 6 for effort but received 9 of type number"

vseventer commented 2 months ago

Yes, this seems to be a bug in the CLI - thanks for reporting.