EreaderReader: dump images function.

This commit is contained in:
John Schember 2009-04-22 19:11:55 -04:00
parent f158c9c643
commit f96cd13f62

View File

@ -202,6 +202,10 @@ class Reader(FormatReader):
return os.path.join(output_dir, 'metadata.opf')
def dump_pml(self):
'''
This is primarily used for debugging and 3rd party tools to
get the plm markup that comprises the text in the file.
'''
pml = ''
for i in range(1, self.header_record.num_text_pages + 1):
@ -209,6 +213,20 @@ class Reader(FormatReader):
return pml
def dump_images(self, output_dir):
'''
This is primarily used for debugging and 3rd party tools to
get the images in the file.
'''
if not os.path.exists(output_dir):
os.makedirs(output_dir)
with CurrentDir(output_dir):
for i in range(0, self.header_record.num_image_pages):
name, img = self.get_image(self.header_record.image_data_offset + i)
with open(name, 'wb') as imgf:
imgf.write(img)
class EreaderMetadata(object):