Class ImageOption

    • Method Detail

      • jpegQualityOf

        public static ImageOption jpegQualityOf​(int quality)
        Define the quality of the jpg image to be returned.
        Parameters:
        quality - an positive integer between 1 and 100.
        Returns:
        an image option for updating the url.
        Throws:
        java.lang.IllegalArgumentException - if quality is not between 1 and 100.
      • widthOf

        public static ImageOption widthOf​(int width)
        Define the width of the image to be represented.
        Parameters:
        width - width in pixel of the image
        Returns:
        an image option to be used for manipulating an image url.
        Throws:
        java.lang.IllegalArgumentException - if width is not positive.
      • heightOf

        public static ImageOption heightOf​(int height)
        Set the height of the output image.
        Parameters:
        height - size of image in pixel.
        Returns:
        an ImageOption changing the height of an output image.
        Throws:
        java.lang.IllegalArgumentException - if height is not positive.
      • fitOf

        public static ImageOption fitOf​(ImageOption.Resize resize)
        Change the behaviour of resizing.

        By default the aspect ratio of the image is preserved when defining a size, or a width and height. Using this method, you can define a different resize behaviour.

        Parameters:
        resize - the behaviour of resizing
        Returns:
        an image option for manipulating a given url.
      • roundedCornerRadiusOf

        public static ImageOption roundedCornerRadiusOf​(float radius)
        Cut corners round.
        Parameters:
        radius - of the inner circle in pixel
        Returns:
        an image option for manipulating a given url.
        Throws:
        java.lang.IllegalArgumentException - if the radius is negative.
      • backgroundColorOf

        public static ImageOption backgroundColorOf​(int color)
        Define a background color.

        The color value must be a hexadecimal value, i.e. 0xFF0000 means red.

        Parameters:
        color - the color in hex to be used.
        Returns:
        an image option for manipulating a given url.
        Throws:
        java.lang.IllegalArgumentException - if the color is less then zero or greater then 0xFFFFFF.
      • backgroundColorOf

        public static ImageOption backgroundColorOf​(int r,
                                                    int g,
                                                    int b)
        Define a background color by its components.

        Each color component must be a hexadecimal in the range from 0 to 255 inclusively.

        Parameters:
        r - the red color component in hex to be used.
        g - the green color component in hex to be used.
        b - the blue color component in hex to be used.
        Returns:
        an image option for manipulating a given url.
        Throws:
        java.lang.IllegalArgumentException - if a component is less then zero or greater then 255.
      • blackBackgroundColor

        public static ImageOption blackBackgroundColor()
        Define a background color as black.
        Returns:
        an image option for manipulating a given url.
      • http

        public static ImageOption http()
        Prefix image urls with http.

        If a protocol (either http or https) was already specified, this one will be taken and this option will not have any effect.

        Returns:
        an image option changing a given url to use insecure http transport.
      • https

        public static ImageOption https()
        Prefix image urls with secure http.

        If a protocol (either http or https) was already specified, this one will be taken and this option will not have any effect.

        Returns:
        an image option changing a given url to use secure http transport.
        Throws:
        java.lang.IllegalArgumentException - if http() or this method was called before.
      • apply

        public java.lang.String apply​(java.lang.String url)
        Apply this image option to a url, replacing and updating this url.
        Parameters:
        url - a url to be handled
        Returns:
        the changed url.
      • getOperation

        public java.lang.String getOperation()
        Return the operation of this option
        Returns:
        a string representing this option.