+ if bytesPerChannel == 1:
+ maximum = int(stream.readline().strip())
+ assert maximum == 255
+ data = stream.read(height * width * channels * bytesPerChannel)
+ if magic == 'PF':
+ # XXX: Image magic only supports single channel floating point images,
+ # so convert to 8bit RGB
+ pixels = array('f', data)
+ pixels *= 255
+ pixels = array('B', pixels)
+ data = pixels.tostring()
+