Skip to content

Instantly share code, notes, and snippets.

@campanalbero
Last active August 3, 2016 17:07
Show Gist options
  • Save campanalbero/c1b7d57f240c14e1e57a79b5d5b03630 to your computer and use it in GitHub Desktop.
Save campanalbero/c1b7d57f240c14e1e57a79b5d5b03630 to your computer and use it in GitHub Desktop.
import sys
import binascii
''' python3 bin.py INPUT.JPG OUTPUT '''
input = open(sys.argv[1], "rb")
data = input.read()
input.close()
app2_mark = bytes([0xFF, 0xE2])
app2_pos = data.index(app2_mark)
app2_len_byte = bytes([data[app2_pos+2], data[app2_pos+3]])
app2_len_int = int.from_bytes(app2_len_byte, 'big')
pos_from = app2_pos + 18
pos_to = app2_pos + 2 + app2_len_int
icc_arr = bytes(data[pos_from : pos_to])
icc = open(sys.argv[2] + ".icc", "wb")
icc.write(icc_arr)
icc.close()
jpg_arr = data[0 : app2_pos] + data[pos_to : len(data)]
jpg = open(sys.argv[2] + ".jpg", "wb")
jpg.write(jpg_arr)
jpg.close()
@campanalbero
Copy link
Author

iTunes add icc profile to jpg copied from iPhone 4.
The code split jpg and icc profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment