Changeset 3436 for pkpgcounter/trunk/pkpgpdls/tiff.py
- Timestamp:
- 10/06/08 00:22:07 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/tiff.py
r3410 r3436 8 8 # the Free Software Foundation, either version 3 of the License, or 9 9 # (at your option) any later version. 10 # 10 # 11 11 # This program is distributed in the hope that it will be useful, 12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 # GNU General Public License for more details. 15 # 15 # 16 16 # You should have received a copy of the GNU General Public License 17 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. … … 34 34 required = [ "cp" ] 35 35 format = "TIFF" 36 def isValid(self) : 36 def isValid(self) : 37 37 """Returns True if data is TIFF, else False.""" 38 38 littleendian = (chr(0x49)*2) + chr(0x2a) + chr(0) … … 40 40 if self.firstblock[:4] in (littleendian, bigendian) : 41 41 return True 42 else : 42 else : 43 43 return False 44 44 45 45 def getJobSize(self) : 46 46 """Counts pages in a TIFF document. 47 47 48 48 Algorithm by Jerome Alet. 49 49 50 50 The documentation used for this was : 51 51 52 52 http://www.ee.cooper.edu/courses/course_pages/past_courses/EE458/TIFF/ 53 53 """ … … 63 63 integerbyteorder = ">I" 64 64 shortbyteorder = ">H" 65 else : 65 else : 66 66 raise pdlparser.PDLParserError, "Unknown file endianness." 67 pos = 4 67 pos = 4 68 68 try : 69 try : 69 try : 70 70 nextifdoffset = unpack(integerbyteorder, minfile[pos : pos + 4])[0] 71 71 while nextifdoffset : … … 74 74 nextifdoffset = unpack(integerbyteorder, minfile[pos : pos + 4])[0] 75 75 pagecount += 1 76 except IndexError : 76 except IndexError : 77 77 pass 78 finally : 78 finally : 79 79 minfile.close() 80 80 return pagecount