Changeset 3436 for pkpgcounter/trunk/pkpgpdls/pil.py
- Timestamp:
- 10/06/08 00:22:07 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/pil.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/>. … … 26 26 try : 27 27 from PIL import Image 28 except ImportError : 28 except ImportError : 29 29 sys.stderr.write("ERROR: You MUST install the Python Imaging Library (python-imaging) for pkpgcounter to work.\n") 30 30 raise pdlparser.PDLParserError, "The Python Imaging Library is missing." … … 34 34 class Parser(pdlparser.PDLParser) : 35 35 """A parser for plain text documents.""" 36 totiffcommands = [ 'convert "%(infname)s" "%(outfname)s"' ] 36 totiffcommands = [ 'convert "%(infname)s" "%(outfname)s"' ] 37 37 required = [ "convert" ] 38 def isValid(self) : 39 """Returns True if data is an image format supported by PIL, else False.""" 38 def isValid(self) : 39 """Returns True if data is an image format supported by PIL, else False.""" 40 40 try : 41 41 image = Image.open(self.filename) 42 except (IOError, OverflowError) : 42 except (IOError, OverflowError) : 43 43 return False 44 else : 44 else : 45 45 self.format = "%s (%s)" % (image.format, image.format_description) 46 46 return True 47 47 48 48 def getJobSize(self) : 49 49 """Counts pages in an image file.""" … … 52 52 try : 53 53 while True : 54 index += 1 54 index += 1 55 55 image.seek(index) 56 except EOFError : 56 except EOFError : 57 57 pass 58 return index 58 return index