rikukissa / node-red-contrib-image-output

🏞 Easy way of previewing and examining images in your flows
MIT License
13 stars 6 forks source link

Thumbnail images #15

Closed bartbutenaers closed 4 years ago

bartbutenaers commented 4 years ago

Hi Riku (@rikukissa) and Dave (@dceejay),

This node is still one of my favorite nodes. But a disadvantage is that the images are pushed via the Node-RED websocket channel, which starts choking very easily when too much data is being pushed through it. And then my flow editor becomes unresponsive.

And since the images will be showed very small inside the flow editor, it has not much use to push the large (original) image through the websocket channel. Indeed they will be resized by the browser anyway, to show it as a small thumbnail image...

To workaround this, I have added a new checkbox to the config screen:

image

This option is deactivated by default (to keep the original behaviour). But when it is activated, the image will be rescaled at server side. I use the width specified on the config screen, and the height is automatically calculated (to keep the same aspect ratio as the original image).

Example input base64 image:

image

Which is being resized to a much smaller string:

image

You will gain more for larger images of course ...

The readme page has been expanded with a "Node configuration" section, that explains that lower bandwith will result in higher cpu usage (due to resizing):

image

The info panel also has been extended:

image

BTW I have used Jimp to resize the images. Perhaps that might be a bit overkill, but I have tried some other image resizing npm libraries: those were based on C++ libraries (like e.g. sharp), which caused a lot of compilation troubles on my Raspberry. So now we have a full Javascript solution. Perhaps not as fast as C++, but then at least nobody has troubles installing it ...

Hope you like this change! Bart

bartbutenaers commented 4 years ago

Seems there are much more delta's as I had expected. Will need to have a look at that first before you guys start reviewing it!

bartbutenaers commented 4 years ago

Will create a new pull request. Sorry !