http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11578
Revision: 11578
Author: drtrigon
Date: 2013-05-24 17:03:42 +0000 (Fri, 24 May 2013)
Log Message:
-----------
bug fix; IOError: unrecognized data stream contents when reading image file
some minor code clean-up
Modified Paths:
--------------
trunk/pywikipedia/catimages.py
trunk/pywikipedia/externals/__init__.py
Modified: trunk/pywikipedia/catimages.py
===================================================================
--- trunk/pywikipedia/catimages.py 2013-05-24 16:25:09 UTC (rev 11577)
+++ trunk/pywikipedia/catimages.py 2013-05-24 17:03:42 UTC (rev 11578)
@@ -1305,7 +1305,7 @@
img = cv2.imread( self.image_path_JPEG, cv.CV_LOAD_IMAGE_COLOR )
if (img == None) or (self.image_size[0] is None):
raise IOError
-
+
# !!! the 'scale' here IS RELEVANT FOR THE DETECTION RATE;
# how small and how many features are detected
scale = max([1., np.average(np.array(img.shape)[0:2]/maxdim)])
@@ -1527,7 +1527,10 @@
# Read a Data Matrix barcode
dm_read = DataMatrix()
img = Image.open(self.image_path_JPEG)
-
+ #if (img == None) or (self.image_size[0] is None):
+ if (self.image_size[0] is None):
+ raise IOError
+
#
http://libdmtx.wikidot.com/libdmtx-python-wrapper
if img.mode != 'RGB':
img = img.convert('RGB')
@@ -1536,7 +1539,7 @@
except IOError:
pywikibot.warning(u'unknown file type
[_recognize_OpticalCodes_dmtxNzbar]')
return
-
+
smallImg = img.resize( (int(img.size[0]/scale), int(img.size[1]/scale)) )
img = smallImg
Modified: trunk/pywikipedia/externals/__init__.py
===================================================================
--- trunk/pywikipedia/externals/__init__.py 2013-05-24 16:25:09 UTC (rev 11577)
+++ trunk/pywikipedia/externals/__init__.py 2013-05-24 17:03:42 UTC (rev 11578)
@@ -302,7 +302,7 @@
mime = mimetypes.guess_type(package['url'],
strict=True)[0].lower().split('/')
lowlevel_warning(u'MIME type: %s' % mime)
- lowlevel_warning(u'Extract package "%s" to %s'
+ lowlevel_warning(u'Extract package "%s" to %s.'
% (module, os.path.join(path, module)))
if len(mime) > 1:
if mime[1] == 'zip':