2
# The Python Imaging Library.
5
# XV Thumbnail file handler by Charles E. "Gene" Cash
8
# see xvcolor.c and xvbrowse.c in the sources to John Bradley's XV,
9
# available from ftp://ftp.cis.upenn.edu/pub/xv/
12
# 98-08-15 cec created (b/w only)
13
# 98-12-09 cec added color palette
14
# 98-12-28 fl added to PIL (with only a few very minor modifications)
17
# FIXME: make save work (this requires quantization support)
23
import Image, ImageFile, ImagePalette
25
# standard color palette for thumbnails (RGB332)
30
PALETTE = PALETTE + (chr((r*255)/7)+chr((g*255)/7)+chr((b*255)/3))
33
# Image plugin for XV thumbnail images.
35
class XVThumbImageFile(ImageFile.ImageFile):
38
format_description = "XV thumbnail image"
45
raise SyntaxError, "not an XV thumbnail file"
47
# Skip to beginning of next line
52
s = self.fp.readline()
54
raise SyntaxError, "Unexpected EOF reading XV thumbnail file"
58
# parse header line (already read)
59
s = string.split(s.strip())
62
self.size = int(s[0]), int(s[1])
64
self.palette = ImagePalette.raw("RGB", PALETTE)
67
("raw", (0, 0)+self.size,
68
self.fp.tell(), (self.mode, 0, 1)
71
# --------------------------------------------------------------------
73
Image.register_open("XVThumb", XVThumbImageFile)