Esempio n. 1
0
    def __init__(self, image, width=None, height=None, crop=False,
            strip_whitespace=False):
        self.image_id = image.id
        self.param_width = width or 0
        self.param_height = height or 0
        self.param_crop = crop
        self.param_strip_whitespace = strip_whitespace

        file = open_file(image.filesystem_path, 'rb')
        (data, format, size) = scale_image(file, width, height, crop,
                strip_whitespace)
        self.path = generate_path('.' + format.lower())
        self.width = size[0]
        self.height = size[1]
        file = create_file(self.filesystem_path, 'wb')
        if hasattr(file, 'fileno'):  # pragma: no cover (for testing only)
            try:
                os.fchmod(file.fileno(), 0o644)
            except io.UnsupportedOperation:  # BytesIO for testing
                pass
        file.write(data)
        file.close()
Esempio n. 2
0
 def scale_image(self, *a, **kw):
     from s4u.image.scale import scale_image
     return scale_image(*a, **kw)