Ejemplo n.º 1
0
    def get_size(self):
        height = self.attrs.get('height', '').strip().rstrip('px')
        width = self.attrs.get('width', '').strip().rstrip('px')

        if width.isdigit() and height.isdigit():
            return int(width), int(height)

        try:
            return imgsz.fromstring(self.raw_data)[1:]
        except ValueError as e:
            logger.error('Error while determing the size of %s, %s', self.url, e)
        return 0, 0
Ejemplo n.º 2
0
    def get_size(self):
        height = self.attrs.get('height', '').strip().rstrip('px')
        width = self.attrs.get('width', '').strip().rstrip('px')

        if width.isdigit() and height.isdigit():
            return int(width), int(height)

        try:
            return imgsz.fromstring(self.raw_data)[1:]
        except ValueError as e:
            logger.error('Error while determing the size of %s, %s', self.url,
                         e)
        return 0, 0
Ejemplo n.º 3
0
    def get_size(self, inode):
        height = inode.get('height', '').strip().rstrip('px')
        width = inode.get('width', '').strip().rstrip('px')
        
        if width.isdigit() and height.isdigit():
            return int(width), int(height)

        if self.fetch_img(inode['src']):
            try:
                return imgsz.fromstring(self.raw_data)[1:]
            except ValueError as e:
                logger.error('Error while determing the size of %s, %s', self.url, e)
                return 0, 0
        return 0, 0
Ejemplo n.º 4
0
    def get_size(self, inode):
        height = inode.get("height", "").strip().rstrip("px")
        width = inode.get("width", "").strip().rstrip("px")

        if width.isdigit() and height.isdigit():
            return int(width), int(height)

        if self.fetch_img(inode["src"]):
            try:
                return imgsz.fromstring(self.raw_data)[1:]
            except ValueError as e:
                logger.error("Error while determing the size of %s, %s", self.url, e)
                return 0, 0
        return 0, 0
Ejemplo n.º 5
0
    def get_size(self, inode):
        height = inode.get('height', '').strip().rstrip('px')
        width = inode.get('width', '').strip().rstrip('px')

        if width.isdigit() and height.isdigit():
            return int(width), int(height)

        if self.fetch_img(inode['src']):
            try:
                return imgsz.fromstring(self.raw_data)[1:]
            except ValueError as e:
                logger.error('Error while determing the size of %s, %s',
                             self.url, e)
                return 0, 0
        return 0, 0
Ejemplo n.º 6
0
#!/usr/bin/env python
# coding:utf-8

import os
import imgsz
import cStringIO

for root, dirs, names in os.walk('.'):
    for name in names:
        filename = os.path.join(root, name)
        data = file(filename, 'rb').read(1024)
        try:
            mime, x, y= imgsz.fromstring(data)
            print '%s %dx%d:' % (mime, x, y), filename
        except ValueError, e:
            print 'ERROR:', filename, e