-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get a JSON string from the encoded image ? #178
Comments
I have a general suggestion that is not specific to lodepng. How about using base64 to encode the PNG binary data a string. Then you can embed the string directly in your JSON document. Base64 is supported by Python. You will probably find the encoding is smaller than what you are trying to do now, because you won't have any backslashed escape sequences. |
@cosinekitty Thanks a lot, this lib solved my problem. Making a hook, do you know about some C lib to work with images (common operations like resize, rotate etc) ? |
Glad I could help. I'm not sure about image operations, but maybe somebody else here will know a good suggestion. |
Hi,
I want to send images encoded with this library plus some metadata as strings to another C program. I have some problems:
The bytes of the encoded image contains many string null terminator characters (
'\0'
) in the middle. So, the C string libs can't create the string from the bytes array. As a work around, I created my own encoder for this special case, which usesmemcpy
C lib function to copy the PNG bytes to my string. But this isn't a valid C string. There are many'\0'
in the middle.The receiver of the data also can't decode the "string" using C JSON libs because of the same reason (null terminator characters (
'\0'
) in the middle). As a work around, I created my own decoder for this special case, which will look for characters like','
to identify the end of the PNG bytes and the start of the other message fields.Is there some better idea ? Maybe there is some lib that implements JSON encoding for the PNG bytes ? I can't find any mention to this in the source code of this lib.
Thanks in advance
The text was updated successfully, but these errors were encountered: