#!/usr/bin/env ruby if ARGV.size != 2 puts "Usage: $0 " exit 1 end FILENAME = ARGV[0] PALETTENAME = ARGV[1] f = File.open(FILENAME) # In a 256-colour PCX file, the palette is stored in the final 768 bytes as RGB # triplets, and the byte before that should be 0x0C: https://en.wikipedia.org/wiki/PCX#Color_palette f.seek(-769, IO::SEEK_END) raise "Check byte is wrong" unless f.read(1) == "\x0C" puts <