'Image format.
0-4   : \'PNG \'. There must be a space after PNG.
4-36  : Image name. Must be exactly 32 bytes long. Pad with  for names shorter than 32 bytes
36-58 : Unknown.
58-60 : Width.
60-62 : Height.
62-...: Raw image data in 8 bit PNG format.'

def _images(self, manifest, image_hrefs):

    images = []
    from calibre.ebooks.oeb.base import OEB_RASTER_IMAGES
    for item in manifest:
        if ((item.media_type in OEB_RASTER_IMAGES) and (item.href in image_hrefs.keys())):
            try:
                im = Image.open(cStringIO.StringIO(item.data)).convert('P')
                im.thumbnail((300, 300), Image.ANTIALIAS)
                data = cStringIO.StringIO()
                im.save(data, 'PNG')
                data = data.getvalue()
                header = 'PNG    '
                header += image_hrefs[item.href].ljust(32, '\x00')[:32]
                header = header.ljust(58, '\x00')
                header += struct.pack('>HH', im.size[0], im.size[1])
                header = header.ljust(62, '\x00')
                if ((len(data) + len(header)) < 65505):
                    images.append((header, data))
            except Exception as e:
                self.log.error(('Error:    Could    not    include    file    %s    becuase    %s.' % (item.href, e)))
    return images
