I’m trying to convert a web app that displays local images to an Electron app, and face a hurdle in that the images displayed, while they do come from the filesystem, are first processed by the Sharp Node.js module, and therefore don’t exist on disk. Currently the web client app loads them from a URL at which the server exposes them after being processed by Sharp. I can think of a couple of approaches:
Have Sharp save the created image to a temporary location, and then reference that as a file:// URL. This has the downside that I would need to manage cleanup of the temp folder, and I would also need to take steps to ensure that the renderer doesn’t attempt to load the file from the disk before Sharp has finished creating it.
Have the main process run a sort of internal web server on localhost to provide http:// URLs that the HTML image element can reference, same as in the current web app.
However, neither seems ideal or the obvious choice, and I wondered if there is a better one that I’m not aware of.