# NR image tools conversion problem

**URL:** https://discourse.nodered.org/t/nr-image-tools-conversion-problem/84881
**Category:** General
**Created:** [24 January 2024 14:19 UTC](https://discourse.nodered.org/t/nr-image-tools-conversion-problem/84881 "2024-01-24T14:19:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![JeromeVISUALS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeromevisuals/32/40103_2.png) [@JeromeVISUALS](https://discourse.nodered.org/u/JeromeVISUALS)
#### Post date: [24 January 2024 14:19 UTC](https://discourse.nodered.org/t/nr-image-tools-conversion-problem/84881/1 "2024-01-24T14:19:12Z")

</div>

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 ?

Many thanks

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [24 January 2024 14:30 UTC](https://discourse.nodered.org/t/nr-image-tools-conversion-problem/84881/2 "2024-01-24T14:30:37Z")

</div>

> [@JeromeVISUALS](#):
>
> and my sender gives me a bmp content

what do you get - a buffer?

> [@JeromeVISUALS](#):
>
> I don't know exactly how Base64 relates to files extensions

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)

> [@JeromeVISUALS](#):
>
> I also tried to save the incoming images on local HDD as .jpg files ( and that works fine)

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

OR

buffer -\> function node `msg.payload = msg.payload.toString('base64')` -\> image node

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [24 January 2024 17:26 UTC](https://discourse.nodered.org/t/nr-image-tools-conversion-problem/84881/3 "2024-01-24T17:26:07Z")

</div>

there is of course [node-red-node-base64](https://flows.nodered.org/node/node-red-node-base64) to help with this as well 🙂

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [24 January 2024 17:27 UTC](https://discourse.nodered.org/t/nr-image-tools-conversion-problem/84881/4 "2024-01-24T17:27:45Z")

</div>

> [@dceejay](#):
>
> there is of course [node-red-node-base64](https://flows.nodered.org/node/node-red-node-base64)

yeah, i could have been a wee bit more explicit when I said ↓ _base64 node_ ↓ 😃

> [@Steve-Mcl](#):
>
> buffer -\> base64 node -\> image node

---

<div class="post-metadata">

### Author: ![JeromeVISUALS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeromevisuals/32/40103_2.png) [@JeromeVISUALS](https://discourse.nodered.org/u/JeromeVISUALS)
#### Post date: [24 January 2024 19:01 UTC](https://discourse.nodered.org/t/nr-image-tools-conversion-problem/84881/5 "2024-01-24T19:01:27Z")

</div>

Hi !

This is what I get from the Rest API call, so for me it looks like correct Base64 encoding.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/08b1341307121f3d38fe6e85f41bd5913ba0cd6d.png)

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 :

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/8/c8d982c9a6a1e6219c1e1dc35dda5c2232911708.png)

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 !

Cheers

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [23 April 2024 19:02 UTC](https://discourse.nodered.org/t/nr-image-tools-conversion-problem/84881/6 "2024-04-23T19:02:00Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
