I have jpeg images stored in binary formats. In need to edit these binaries to delete all the byte pairs that come before 0xff 0xd8
(as this is the initial part of my jpegs).
The reason is that when I try to view these files in an image program, they won't open as long as I don't get rid of all the part of bytearray coming before this 0xff 0xd8
bytes.
Here's what I tried so far:
data= open ('C:/Users/Umberto/Desktop/_BR_Browse.001_2065642654_1.BINARY', 'rb+')
edit= str (data.read () )
data.close ()
edit.find ('/xff/xd8')
but I always receive '-1' as index, for whatever I put as argument using "find" method. What's wrong with the code?
Once I know the position of /xff/xd8
, I would simply delete what comes before it somehow.