Beispiel #1
0
    def validate_request(self):
        self._validate_operation()
        self._validate_url()
        self._validate_signature()
        self._validate_client()
        self._validate_host()

        opts = self._get_save_options()
        ops = self._get_operations()
        if "resize" in ops:
            w, h = self.get_argument("w"), self.get_argument("h")
            Image.validate_dimensions(w, h)
            if w and int(w) > self.settings.get("max_resize_width"):
                raise errors.DimensionsError("Exceeds maximum allowed width")
            elif h and int(h) > self.settings.get("max_resize_height"):
                raise errors.DimensionsError("Exceeds maximum allowed height")
            opts.update(self._get_resize_options())
        if "rotate" in ops:
            Image.validate_degree(self.get_argument("deg"))
            opts.update(self._get_rotate_options())
        if "region" in ops:
            Image.validate_rectangle(self.get_argument("rect"))
        if "watermark" in ops:
            url = self.get_argument("watermark_img")
            text = self.get_argument("watermark_txt")
            if url and not url.startswith("http://") and not url.startswith(
                    "https://"):
                raise errors.DimensionsError("Unsupported protocol")
            if text is not None and not text:
                raise errors.DimensionsError("Watermark text cannot be empty")
            if text is None and url is None:
                raise errors.DimensionsError(
                    "Watermark requires either watermark_img or watermark_txt")

        Image.validate_options(opts)
Beispiel #2
0
    def validate_request(self):
        self._validate_operation()
        self._validate_url()
        self._validate_signature()
        self._validate_client()
        self._validate_host()

        opts = self._get_save_options()
        ops = self._get_operations()
        if "resize" in ops:
            w, h = self.get_argument("w"), self.get_argument("h")
            Image.validate_dimensions(w, h)
            if w and int(w) > self.settings.get("max_resize_width"):
                raise errors.DimensionsError("Exceeds maximum allowed width")
            elif h and int(h) > self.settings.get("max_resize_height"):
                raise errors.DimensionsError("Exceeds maximum allowed height")
            opts.update(self._get_resize_options())
        if "rotate" in ops:
            Image.validate_degree(self.get_argument("deg"))
            opts.update(self._get_rotate_options())
        if "region" in ops:
            Image.validate_rectangle(self.get_argument("rect"))
        if "scale-ar" in ops:
            Image.validate_scale_ar_options(self.get_argument("ar"))

        Image.validate_options(opts)
Beispiel #3
0
    def _validate_request(self):
        self._validate_operation()
        self._validate_url()
        self._validate_signature()
        self._validate_client()
        self._validate_host()

        opts = self._get_save_options()
        ops = self._get_operations()
        if "resize" in ops:
            Image.validate_dimensions(self.get_argument("w"), self.get_argument("h"))
            opts.update(self._get_resize_options())
        if "rotate" in ops:
            Image.validate_degree(self.get_argument("deg"))
            opts.update(self._get_rotate_options())
        if "region" in ops:
            Image.validate_rectangle(self.get_argument("rect"))

        Image.validate_options(opts)
Beispiel #4
0
    def _validate_request(self):
        self._validate_operation()
        self._validate_url()
        self._validate_signature()
        self._validate_client()
        self._validate_host()

        opts = self._get_save_options()
        ops = self._get_operations()
        if "resize" in ops:
            Image.validate_dimensions(self.get_argument("w"),
                                      self.get_argument("h"))
            opts.update(self._get_resize_options())
        if "rotate" in ops:
            Image.validate_degree(self.get_argument("deg"))
            opts.update(self._get_rotate_options())
        if "region" in ops:
            Image.validate_rectangle(self.get_argument("rect"))

        Image.validate_options(opts)
Beispiel #5
0
    def validate_request(self):
        self._validate_operation()
        self._validate_url()
        self._validate_signature()
        self._validate_client()
        self._validate_host()

        opts = self._get_save_options()
        ops = self._get_operations()
        if "resize" in ops:
            w, h = self.get_argument("w"), self.get_argument("h")
            Image.validate_dimensions(w, h)
            if w and int(w) > self.settings.get("max_resize_width"):
                raise errors.DimensionsError("Exceeds maximum allowed width")
            elif h and int(h) > self.settings.get("max_resize_height"):
                raise errors.DimensionsError("Exceeds maximum allowed height")
            opts.update(self._get_resize_options())
        if "rotate" in ops:
            Image.validate_degree(self.get_argument("deg"))
            opts.update(self._get_rotate_options())
        if "region" in ops:
            Image.validate_rectangle(self.get_argument("rect"))

        Image.validate_options(opts)