Esempio n. 1
0
 def testImageSizesWithoutPIL(self):
     hasPIL = utils.hasPIL
     utils.hasPIL = False
     self.assertEqual(getImageSize(getFile('image.gif')), (200, 200))
     self.assertEqual(getImageSize(getFile('image.png')), (500, 200))
     # the fallback method cannot handle jpegs properly
     self.assertEqual(getImageSize(getFile('image.jpg')), (-1, -1))
     utils.hasPIL = hasPIL
Esempio n. 2
0
 def testImageSizesWithoutPIL(self):
     hasPIL = utils.hasPIL
     utils.hasPIL = False
     self.assertEqual(getImageSize(getFile('image.gif')), (200, 200))
     self.assertEqual(getImageSize(getFile('image.png')), (500, 200))
     # the fallback method cannot handle jpegs properly
     self.assertEqual(getImageSize(getFile('image.jpg')), (-1, -1))
     utils.hasPIL = hasPIL
Esempio n. 3
0
def patched_getSize(self):
    """ Return image dimensions of the blob
    """
    try:
        blob = openBlob(self.blob)
    except POSKeyError:

        oid = self.blob._p_oid

        directories = []
        # Create the bushy directory structure with the least significant byte
        # first
        for byte in str(oid):
            directories.append('0x%s' % binascii.hexlify(byte))
        path = os.path.sep.join(directories)
        cached = self.blob._p_blob_committed

        logger.error("BLOBWARNING: Could not get "
                     "image size for blob %r. Info about blob: "
                     "OID (oid, repr, path on zeo storage): %r > %r > %r "
                     "CACHED (path to cached blob): %r ",
                     self.blob._p_oid, oid_repr(oid),
                     oid.__repr__(), path, cached)

        return 0

    size = getImageSize(blob)
    blob.close()
    return size
Esempio n. 4
0
 def getSize(self):
     """ return image dimensions of the blob """
     # TODO: this should probably be cached...
     blob = openBlob(self.blob)
     size = getImageSize(blob)
     blob.close()
     return size
Esempio n. 5
0
 def getSize(self):
     """ return image dimensions of the blob """
     # TODO: this should probably be cached...
     blob = openBlob(self.blob)
     size = getImageSize(blob)
     blob.close()
     return size
Esempio n. 6
0
def patched_getSize(self):
    """ Return image dimensions of the blob
    """
    try:
        blob = openBlob(self.blob)
    except POSKeyError:

        oid = self.blob._p_oid

        directories = []
        # Create the bushy directory structure with the least significant byte
        # first
        for byte in str(oid):
            directories.append('0x%s' % binascii.hexlify(byte))
        path = os.path.sep.join(directories)
        cached = self.blob._p_blob_committed

        logger.error(
            "BLOBWARNING: Could not get "
            "image size for blob %r. Info about blob: "
            "OID (oid, repr, path on zeo storage): %r > %r > %r "
            "CACHED (path to cached blob): %r ", self.blob._p_oid,
            oid_repr(oid), oid.__repr__(), path, cached)

        return 0

    size = getImageSize(blob)
    blob.close()
    return size
Esempio n. 7
0
 def testImageSizes(self):
     self.assertEqual(getImageSize(getFile('image.gif')), (200, 200))
     self.assertEqual(getImageSize(getFile('image.png')), (500, 200))
     self.assertEqual(getImageSize(getFile('image.jpg')), (500, 200))
Esempio n. 8
0
 def testImageSizes(self):
     self.assertEqual(getImageSize(getFile('image.gif')), (200, 200))
     self.assertEqual(getImageSize(getFile('image.png')), (500, 200))
     self.assertEqual(getImageSize(getFile('image.jpg')), (500, 200))