tet.pcos_get_string(doc, "colorspaces[%d]/name" % cs ))) else: # cs==-1 may happen for some JPEG 2000 images. bpc, # colorspace name and number of components are not # available in this case. print("JPEG2000") # Fetch image data and write it to a disk file. The # output filename is generated from the input filename, # page number and image ID. imageoptlist = baseimageoptlist + " filename {" + outfilebase + "_p" + repr(pageno) + "_I" + repr(ti["imageid"]) + "}" if (tet.write_image_file(doc, ti["imageid"], imageoptlist) == -1): print("Error " + tet.get_errnum() + " in " + tet.get_apiname() + "(): " + tet.get_errmsg()) ti = tet.get_image_info(page) if (tet.get_errnum() != 0): raise Exception ("Error " + repr(tet.get_errnum()) \ + "in " + tet.get_apiname() + "() on page " + \ repr(pageno) + ": " + tet.get_errmsg() ) tet.close_page(page) tet.close_document(doc) except TETException:
txt = txt + ", mergetype=" if (mergetype == 1): txt = txt + "artificial" else: txt = txt + "consumed" print(txt) # Fetch the image data and write it to a disk file. The # output filenames are generated from the input filename # by appending page number and image number. # imageoptlist = "%s filename={%s_I%d}" % \ (baseimageoptlist, outfilebase, imageid) if (tet.write_image_file(doc, imageid, \ imageoptlist) == -1): print("\nError " + repr(tet.get_errnum()) + "in " + \ tet.get_apiname() + "():" + tet.get_errmsg()) continue # process next image */ tet.close_document(doc) except TETException: print("TET exception occurred:\n[%d] %s: %s" % ((tet.get_errnum()), tet.get_apiname(), tet.get_errmsg())) print_tb(exc_info()[2]) except Exception: print("Exception occurred: %s" % (exc_info()[0])) print_exc()