Papyrix's HTML renderer defers to another support library to dispatch to the appropriate code (wrapped in an adaptor) for preparing an image to be rendered onscreen.
This includes a JPEG converter that considers taking shortcuts, a PNG converter with a "quickmode", & a BMP backend that merely copies the file into place.
It wraps a FsHelpers support library to determine the image's filetype, & in turn which of these backends it should use.
1/2?
And there's a method that carefully retrieves the appropriate backend, validates there's enough RAM, opens the input & output files, runs the conversion, renames the output into place or removes failures, & logs some specs.
That FsHelpers support library has routines to check for certain files/folders it hides, to normalize a filepath, & to check for various extensions. Those extension helpers are inlined.
2/2 Fin for today! Tomorrow: JPEG!