google/guetzli

ReadFileOrDie: string to char*

leafjungle opened this issue · 1 comments

source file: guetzli/gutezli.cc
std::string in_data = ReadFileOrDie(argv[opt_idx]);

I modify it as :
std::string in_data_1 = ReadFileOrDie(argv[opt_idx]);
const char* t1 = in_data_1.c_str();
std::string in_data = t1;

Recompile, run the bin/Release/guetzli, And I got the error:
Unexpected end of input: pos=4 need=2 len=4
Error reading JPG data from input file

But why?



Explain why I try to that.
I add a guetzli_dynamic.make, and a interface source interface.cc to make a dynamic shared lib: guetzli_dynamic.so.
extern "C" const char* compress(const char* in_data_1, const int _quality)

And I call the method by python . The image is read by python, and pass the raw jpg image content to compress function. The result is the same as above.(Unexpected end of input)

because of 0-character stops the c_str-kind of string