src/reportlab/pdfgen/pdfimages.py
branchpy33
changeset 3723 99aa837b6703
parent 3721 0c93dd8ff567
child 3731 b233dd0577ff
--- a/src/reportlab/pdfgen/pdfimages.py	Sun Feb 17 12:13:56 2013 +0000
+++ b/src/reportlab/pdfgen/pdfimages.py	Tue Apr 30 14:28:14 2013 +0100
@@ -7,13 +7,11 @@
 """
 
 import os
-import string
-from types import StringType
 import reportlab
 from reportlab import rl_config
 from reportlab.pdfbase import pdfutils
 from reportlab.pdfbase import pdfdoc
-from reportlab.lib.utils import fp_str, getStringIO
+from reportlab.lib.utils import fp_str, getBytesIO, isStrType
 from reportlab.lib.utils import import_zlib, haveImages
 from reportlab.lib.boxstuff import aspectRatioFix
 
@@ -85,7 +83,7 @@
         cachedname = os.path.splitext(image)[0] + (rl_config.useA85 and '.a85' or '.bin')
         imagedata = open(cachedname,'rb').readlines()
         #trim off newlines...
-        imagedata = list(map(string.strip, imagedata))
+        imagedata = list(map(str.strip, imagedata))
         return imagedata
 
     def PIL_imagedata(self):
@@ -129,16 +127,16 @@
             imagedata = pdfutils.cacheImageFile(image,returnInMemory=1)
         else:
             imagedata = self.cache_imagedata()
-        words = string.split(imagedata[1])
-        imgwidth = string.atoi(words[1])
-        imgheight = string.atoi(words[3])
+        words = imagedata[1].split()
+        imgwidth = int(words[1])
+        imgheight = int(words[3])
         return imagedata, imgwidth, imgheight
 
     def getImageData(self,preserveAspectRatio=False):
         "Gets data, height, width - whatever type of image"
         image = self.image
 
-        if type(image) == StringType:
+        if isStrType(image):
             self.filename = image
             if os.path.splitext(image)[1] in ['.jpg', '.JPG', '.jpeg', '.JPEG']:
                 try:
@@ -189,7 +187,7 @@
         dict['Height'] = self.height
         dict['BitsPerComponent'] = 8
         dict['ColorSpace'] = pdfdoc.PDFName(self.colorSpace)
-        content = string.join(self.imageData[3:-1], '\n') + '\n'
+        content = '\n'.join(self.imageData[3:-1]) + '\n'
         strm = pdfdoc.PDFStream(dictionary=dict, content=content)
         return strm.format(document)