Last active
September 15, 2022 14:32
-
-
Save danielsharvey/929a525712a2b89ebb561226cc32f3e7 to your computer and use it in GitHub Desktop.
Converting iPhone iOS '.cpbitmap' images to PNGs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from PIL import Image,ImageOps | |
import struct | |
import sys | |
if len(sys.argv) < 3: | |
print "Need two args: source_filename and result_filename\n"; | |
sys.exit(0) | |
filename = sys.argv[1] | |
result_filename = sys.argv[2] | |
with open(filename) as f: | |
contents = f.read() | |
unk1, width, height, unk2, unk3, unk4 = struct.unpack('<6i', contents[-24:]) | |
im = Image.frombytes('RGBA', (width,height), contents, 'raw', 'RGBA', 0, 1) | |
r,g,b,a = im.split() | |
im = Image.merge('RGBA', (b,g,r,a)) | |
im.save(result_filename) |
Looks like iOS 13 broke all of these.
Also needs to be converted to python3/PIL7. Thankfully I have a iOS12 backup still and gentoo gives me every python/PIL combo I could ever want.
@sh00tg0a1 Thanks
A browser based version I created based off of that Node.js Stack Overflow answer. It works in all modern browsers and should work with all versions of iOS so far: https://cpbitmap.github.io/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sh00tg0a1 not working with this message: