Python3, binary data diffrent representation from what i need

I have to add an image to a database, so I open the image as binary and it stores it this way:


However I need it to be strored this way:


It is my first ever time working with binary files so there is probably something basic I’m not understanding.

This is my code for opening the image in python:

with open("1x1.jpg", 'rb') as File:

This is the image: (1×1 empty pixel, I changed the extension from png to jpg, the original image is from×1.png)
1x1 empty pixel

>Solution :

binaryData is bytes and you need to convert it to the hex format.




Leave a Reply