Scavenging JPEG data out of Pict files

Macintosh SE/30

I have some pretty old files on my disk, often in formats that are not that easy to read anymore, like old Quickdraw Pict files. I could start OS 6 or 7 inside an emulator and convert them into a more modern format there, but these particular images are bitmaps compressed using Quicktime, which just embedded the JPEG data. So I wrote a quick and very dirty Python script to get that part out.

The script is not particularly smart, and does a lot of things wrong, in particular it won’t search for the end of the JPEG data, and will therefore copy Quickdraw garbage at the end of the JPEG file, most programs don’t care, so this should be enough to open the data in a regular editor at save it into a saner file.

As usual, use this script at your own risk.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

def main(path):
  with open(path, mode='rb') as input_file:
    data = input_file.read()
    match = data.find(bytes.fromhex('FFD8'))
    if match >= 0:
      with open(path + '.jpg', mode='wb') as output_file:
        output_file.write(data[match:])
    else:
      sys.stderr.write('No JPEG marker found in %s\n' % path)

if __name__ == '__main__':
  main(sys.argv[1])

Macintosh SE/30 image Creative Commons Attribution-Share Alike 2.5 Generic.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.