: If you are experiencing mysterious "broken" images in your application, enabling a stricter failOn setting can help you identify exactly which source files are corrupted during the ingestion phase. Practical Implementation Example
Internal changes in libvips integration made the engine stricter. Some images that previously "passed" with 'none' began throwing Premature end of input file errors regardless of the setting.
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.
Sometimes an image has valid metadata (width/height) but corrupted pixel data. Using failOn: 'warning' (default) is the safest way to validate that an image is fully processable before storing it. If you'd like to explore this further, I can provide: A performance comparison between different failOn levels. A guide on validating user uploads using this option. Troubleshooting steps for specific VipsJpeg errors . Truncated JPGs And Sharp Version · Issue #3624 - GitHub