Showing results for 
Search instead for 
Did you mean: 

Image to Base64 !error!

Go to solution

Good brothers! I have a problem!


I want to encode the image as Base64. But the base64 string is wrong! It is completely different from the base64 data I encoded on the web page. The data on the web page is correct!

What's wrong with my program? Which VI is used incorrectly?

I put screenshots, source code, correct Base64 data, pictures. Put it down
Thank you for helping me answer
Thank you!!!

0 Kudos
Message 1 of 9

Nothing is wrong with base64 encode/decode. You compare different data.

0 Kudos
Message 2 of 9

Then why do I use the same picture ("1. png") to encode Base64 on the web page online, and the result is different from that of LabVIEW?

0 Kudos
Message 3 of 9

Base64 encoding using the same image:

Results of online page coding: please see the appendix "correct-base64. TXT"

Results of LabVIEW coding: please see the appendix "labview-base64. JPG"

Download All
0 Kudos
Message 4 of 9

There's probably an error with the data from the online converter.


Not that the routine is wrong, but the data you paste there might be the wrong encoding or something like that.


I've compared the data in LabVIEW with a completely different Base64 implementation, and that encoding is correct.


You're only telling half the story. "There's no match, so LabVIEW must be wrong".


How did you get the online result?


Looking at the online result, it seems more like the image was compressed before the Base64 encoding. Perhaps a jpg was encoded? Or a compressed png maybe?



Using Base64 Decode and Encode - Online and Base64 Decode and Encode - Online I converted the PNG to Base64 (using files, not copy paste). The data looks like your 'correct' data. However, decoding LabVIEW's result, does result in a valid PNG as well.


It looks to me like Base64 encoding doesn't need to be unique. So there can be more valid encodings for data...

Message 5 of 9

wiebe@CARYA wrote:

However, decoding LabVIEW's result, does result in a valid PNG as well.


I can confirm this e.g.

0 Kudos
Message 6 of 9


I have listened to your views in detail
I agree with you that there are many more effective coding methods
However, because I need to communicate with the network API, I must use the base64 code required by the customer.

I used the encoding website you sent to encode the image "1. PNG".
The result of the website is what I want. (confirmed with the customer that they used Python to Base64 encode the image "1. PNG", and the result is the same as that of the website.)

The result of Base64 encoding in LabVIEW is not what I want.
How can I change my program to make the results of LabVIEW coding consistent with the website?

0 Kudos
Message 7 of 9



Thank you very much for helping me solve this problem

Do you know why the website code is different from my LabVIEW code?
The website coding is obviously correct (I have verified with the customer, and he used Python to code my pictures, and the results are consistent with the website)

0 Kudos
Message 8 of 9
Accepted by topic author edc777

As I wrote above, you compare different data.


You must read the 1.png file using the labview function "Read from Binary File". Then encode the read string. This is what your webserver do. This gives the same result as in your "correct-base64.txt" file.


If you decode the PNG file and encode the image using a differnt algorithm, you'll get a different png file.


Message 9 of 9