google / guetzli

Perceptual JPEG encoder
Apache License 2.0
12.92k stars 978 forks source link

ReadFileOrDie: string to char* #230

Closed leafjungle closed 7 years ago

leafjungle commented 7 years ago

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)

jyrkialakuijala commented 7 years ago

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