Sharp Failon Option ((install)) -
: Only halts processing on fatal errors that make it impossible to render the output image. Why is this Option Important?
| Goal | Implementation Strategy | | :--- | :--- | | | Wrap sharp() call in try/catch (standard error handling). | | Fail on truncated data | Check info.truncated in the callback/buffer return object. | | Fail on dimensions | Run .metadata() first, then throw custom error based on width/height. | | Fail on oversized files | Use the .limitInputPixels() option. |
To allow a slightly corrupted JPEG (common with some mobile device uploads) to still be processed, you would use: javascript sharp failon option
In Sharp, there isn't a single option named failOn . Instead, "failing" is controlled via specific options depending on what you want to catch (metadata errors, truncated images, or invalid input).
: This is a common middle ground. If the underlying library (libvips) issues a warning—such as a truncated ICC profile or a slightly corrupted header—the process will terminate and throw an error. : Only halts processing on fatal errors that
By default, if you pass a non-image file (like a text file or PDF) to Sharp, it might not throw an error immediately depending on how it is buffered. To ensure Sharp fails strictly on invalid input, rely on or try/catch blocks.
To force a failure on truncated images, check the info object returned after processing. | | Fail on truncated data | Check info
Could you clarify the context? With a little more detail (book, game, industry, or a phrase you saw), I can write the full backstory or explanation for you.