Hi, there, I have a problem with image tools, which I use quite often without any problem.
My workflow is to get a base64 encoded image from a http GET request, and send back that base64 to another device using TCP connection, so far so good.
The problems is that receiver expects some JPEG content, and my sender gives me a bmp content ( at least this is how it is described in MIMI information ).
I don't know exactly how Base64 relates to files extensions, but I guess there might be some link, at least due to JPEG compression.
I tried many things but can't get it to work, I also tried to save the incoming images on local HDD as .jpg files ( and that works fine) , to reopen them just after in the same flow, but the results in the same in the end....
What do I miss ? Is there any easier way to handle this image conversion ?
what do you get - a buffer?
Base64 is just a representation of some bytes as printable characters - you cannot simply save this to a *.jpg file and expect it to work - they need to be base64 decoded (which is what the Image Tools does)
that indicates to me you are getting a
buffer of real JPG image data, so you should be able to feed that buffer into the image node - or - you might have to run it through a base64 conversion first
buffer -> base64 node -> image node
buffer -> function node
msg.payload = msg.payload.toString('base64') -> image node
there is of course node-red-node-base64 to help with this as well
yeah, i could have been a wee bit more explicit when I said ↓ base64 node ↓
This is what I get from the Rest API call, so for me it looks like correct Base64 encoding.
Then I go through a image node for some processing and write to HDD using a image node in write mode, connected to another image node set with the same filename to open the file :
Actually I made a mistake in my first message, the write node was set to a fake filename so the reader node was working with a previous file.....
However I don't know what I did change in the end, but it all works now as expected, the receiver gets the base64 image correctly, all without going through this write/read to HDD process.
I'll clean all that tomorrow when back in the office and will come back with some details, if helpful for others.
Many thanks for your willing to help !