So I have this code in python that converts image into base64. And I have this code in C# winforms that collects that base64 and converts it again in image.
Python Code:
import base64
imgtob64 = open('Resources/yudodis.jpg', 'rb')
imgtob64_read = imgtob64.read()
imgb64encode = base64.encodebytes(imgtob64_read)
print(imgb64encode)
C# Code:
string TestPath3 = @"C:\Users\chesk\Desktop\imagetobase64.py";
string b64stringPython;
string error;
var startProcess = new ProcessStartInfo
{
FileName = pythonInterpreter, Arguments = string.Format($"\"{TestPath3}\""),
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardInput = true,
RedirectStandardError = true,
CreateNoWindow = true,
};
using (Process process = Process.Start(startProcess))
{
try
{
error = process.StandardError.ReadToEnd();
b64stringPython = process.StandardOutput.ReadToEnd();
lblTestOutput.Text = b64stringPython;
lblError.Text = error;
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}
Codes on both sides are both working fine if I'm using a small image that consist of less than 4,000 base64. The system in C# suddenly stop working (or suddenly stop accepting data from python based on my understanding) when I'm sending base64 data that consist of more than 5,000 base64.
What do you think might be the problem with this? Why does C# having a problem accepting a huge amount of standard output from python?