-
Notifications
You must be signed in to change notification settings - Fork 4
ImageKitURLConstructor
Method to specify the width of the output image.
-
Parameters:
width
— Accepts integer value greater than 1 and if a value between 0 and 1 is specified, then it acts as a percentage width.For eg, 0.1 means 10% of the original width, 0.2 means 20% of the original width.
-
Returns: the current ImagekitUrlConstructor object.
Method to specify the height of the output image.
-
Parameters:
height
— Accepts integer value greater than 1 and if a value between 0 and 1 is specified, then it acts as a percentage height.For eg, 0.1 means 10% of the original height, 0.2 means 20% of the original height.
-
Returns: the current ImagekitUrlConstructor object.
Method to specify the aspect ratio of the output image or the ratio of width to height of the output image. This transform must be used along with either the height or the width transform.
-
Parameters:
-
width
— Accepts integer value greater than equal to 1 -
height
— Accepts integer value greater than equal to 1
-
- Returns: the current ImagekitUrlConstructor object.
Method to decide the final value of height and width of the output image based on the aspect ratio of the input image and the requested transform.
-
Parameters:
cropType
— Accepts value of type CropType. Possible values include maintain_ratio, force, at_least and at_max.Default value - maintain_ratio
-
See also: CropType
-
Returns: the current ImagekitUrlConstructor object.
Method used to specify the strategy of how the input image is used for cropping to get the output image.
-
Parameters:
cropMode
— Accepts value of type CropMode. Possible values include resize, extract, pad_extract and pad_resize.Default value - resize
-
See also: CropMode
-
Returns: the current ImagekitUrlConstructor object.
Method used to specify the focus which is coupled with the extract type of crop mode (crop mode is not needed if you are using auto focus) to get the area of the input image that should be focussed on to get the output image.
-
Parameters:
focusType
— Accepts value of type FocusType. Possible values include center, top, left, bottom, right,top_left, top_right, bottom_left, bottom_right and auto.
Default value - center
-
See also: FocusType
-
Returns: the current ImagekitUrlConstructor object.
Method to specify the output quality of the lossy formats like JPG and WebP. A higher quality number means a larger size of the output image with high quality. A smaller number means low quality image at a smaller size.
-
Parameters:
quality
— Accepts integer value between 1 and 100.Default value is picked from the dashboard settings. It is set to 80.
-
Returns: the current ImagekitUrlConstructor object.
Method used to specify the format of the output image. If no output format is specified and the “Dynamic image format selection” option is selected in your dashboard settings, then the output format is decided on the basis of the user’s device capabilities and input image format. If dynamic image format selction is switched off, and no output format is specified then the format of the output image is same as that of the input image.
-
Parameters:
format
— Accepts value of type FocusType. Possible values include auto, webp, jpg, jpeg and pnt.Default value - auto
-
See also: Format
-
Returns: the current ImagekitUrlConstructor object.
Method to specify the Gaussian blur that has to be applied to the image. The value of blur decides the radius of the Gaussian blur that is applied. Higher the value, higher is the radius of Gaussian blur.
-
Parameters:
blur
— Accepts integer value between 1 and 100. - Returns: the current ImagekitUrlConstructor object.
Method to turn an image into its grayscale version.
-
Parameters:
flag
— Accepts boolean value of either true or false. Default value is false. - Returns: the current ImagekitUrlConstructor object.
Method to specify the device pixel ratio to be used to calculate the dimension of the output image. It is useful when creating image transformations for devices with high density screens (DPR greater than 1) like the iPhone. The DPR option works only when either the height or the width or both are specified for resizing the image If the resulting height or width after considering the specified DPR value is less than 1px or more than 5000px then the value of DPR is not considered and the normal height or width specified in the transformation string is used.
-
Parameters:
dpr
— Possible values: 0.1 to 5.0 - Returns: the current ImagekitUrlConstructor object.
Method to specify the Named transformations which is an alias for the entire transformation string. E.g we can create a named transform media_library_thumbnail for transformation string tr:w-150,h-150,f-center,c-at_max
-
Parameters:
namedTransformation
— - Returns: the current ImagekitUrlConstructor object.
Method to specify the default image which is delivered in case the image that is requested using ImageKit does not exist.
-
Parameters:
defaultImage
— - Returns: the current ImagekitUrlConstructor object.
Method to specify if the output JPEG image should be rendered progressively. In progressive rendering, the client instead of downloading the image row-wise (baseline loading), renders a low-quality pixelated full image and then gradually keeps on adding more pixels and information to the image. It gives faster-perceived load times.
-
Parameters:
flag
— Possible values include true and false. Default value - false - Returns: the current ImagekitUrlConstructor object.
Method to specify if the output image (if in PNG or WebP format) should be compressed losslessly. In lossless compression, the output file size would be larger than the regular lossy compression but at the same time, the perceived quality can be better in certain cases, especially for computer generated graphics. Using lossless compression is not recommended for photographs.
-
Parameters:
flag
— Possible values include true and false. Default value - false - Returns: the current ImagekitUrlConstructor object.
Method to specify if the redundant pixels of the original image need to be removed. It uses a default logic to identify the redundant surrounding region and removes it. This transformation is useful for images that have a solid / nearly-solid background and the object in the center. This transformation will trim the background from the edges, leaving only the central object in the picture.
-
Parameters:
flag
— Possible values include true and false. - Returns: the current ImagekitUrlConstructor object.
- See also: trim
Method to specify the number of redundant pixels of the original image that need to be removed. This transformation is useful for images that have a solid / nearly-solid background and the object in the center. This transformation will trim the background from the edges, leaving only the central object in the picture.
-
Parameters:
value
— Number of pixels from the edge that need to be removed across all four sides. - Returns: the current ImagekitUrlConstructor object.
- See also: trim
Method to specify an image to overlay over another image. This will help you generate watermarked images if needed.
-
Parameters:
overlayImage
— - Returns: the current ImagekitUrlConstructor object.
Method used to specify the position of the overlaid image relative to the input image.
-
Parameters:
overlayFocus
— Possible values include center, top, left, bottom, right, top_left, top_right, bottom_left and bottom_right.Default value - center
-
See also: OverlayFocusType
-
Returns: the current ImagekitUrlConstructor object.
using either overlayPosX() or overlayPosY()
Method used to provide more granular control over the positioning of the overlay image on the input image. The top left corner of the input image is considered as (0,0) and the bottom right corner is considered as (w, h) where w is the width and h is the height of the input image. Negative values are supported with a leading capital N in front of the value provided. The value provided is subtracted from the original dimension of the image & positioned accordingly.
-
Parameters:
overlayX
— Possible values include all integers. -
Returns: the current ImagekitUrlConstructor object.
or the overlay focus has already been applied
Method used to provide more granular control over the positioning of the overlay image on the input image. The top left corner of the input image is considered as (0,0) and the bottom right corner is considered as (w, h) where w is the width and h is the height of the input image. Negative values are supported with a leading capital N in front of the value provided. The value provided is subtracted from the original dimension of the image & positioned accordingly.
-
Parameters:
overlayY
— Possible values include all integers. -
Returns: the current ImagekitUrlConstructor object.
or the overlay focus has already been applied
Method used to specify the width of the overlaid image.
-
Parameters:
overlayWidth
— - Returns: the current ImagekitUrlConstructor object.
Method used to specify the height of the overlaid image.
-
Parameters:
overlayHeight
— - Returns: the current ImagekitUrlConstructor object.
Method used to overlay text over an image. Our current support is limited to alphanumberic & special characters _ & - only.
-
Parameters:
overlayText
— - Returns: the current ImagekitUrlConstructor object.
Method used to specify the color of the overlaid text on the image.
-
Parameters:
overlayTextColor
— Possible value is a valid valid RGB Hex Code - Returns: the current ImagekitUrlConstructor object.
Method used to specify the font family for the overlaid text.
-
Parameters:
overlayTextFontFamily
— - Returns: the current ImagekitUrlConstructor object.
- See also: overlayTextFontFamily
Method used to specify the size of the overlaid text.
-
Parameters:
overlayTextFontSize
— Possible values include any integer. Default value - 14px - Returns: the current ImagekitUrlConstructor object.
Method used to specify the typography of the font family used for the overlaid text. Possible values include bold b and italics i. Note Bold & Italics are not supported for all provided fonts.
-
Parameters:
overlayTextTypography
— - Returns: the current ImagekitUrlConstructor object
- See also: OverlayTextTypography
Method used to specify the colour of background canvas to be overlaid. Possible values include a valid RGB Hex code.
-
Parameters:
overlayBackground
— - Returns: the current ImagekitUrlConstructor object.
Method used to specify the transparency level for the overlaid image. Note Overlay transparency is currently supported for overlay texts & backgrounds only.
-
Parameters:
overlayAlpha
— Possible values include integer from 1 to 9. - Returns: the current ImagekitUrlConstructor object.
Method used to specify if the output image should contain the color profile that is initially available from the original image. It is recommended to remove the color profile before serving the image on web and apps. However, in cases where you feel that the image looks faded or washed-out after using ImageKit and want to preserve the colors in your image, then you should set this option to true. Possible values include true and false.
-
Parameters:
flag
— Default value - false - Returns: the current ImagekitUrlConstructor object.
Method used to specify if the output image should contain all the metadata that is initially available from the original image. Enabling this is not recommended because this metadata is not relevant for rendering on the web and mobile apps. The only reason where you should enable the metadata option is when you have knowingly wanted the additional data like camera information, lens information and other image profiles attached to your image. Possible values include true and false.
-
Parameters:
flag
— Default value - false - Returns: the current ImagekitUrlConstructor object.
Method used to specify the degrees by which the output image has to be rotated or specifies the use of EXIF Orientation tag for the rotation of the image using auto.
-
Parameters:
rotation
— Possible values include 0, 90, 180, 270, 360 and auto.Default value - center
-
See also: Rotation
-
Returns: the current ImagekitUrlConstructor object.
Method used to specify the radius to be used to get a rounded corner image. This option is applied after resizing of the image, if any.
-
Parameters:
radius
— Possible values include positive integer. - Returns: the current ImagekitUrlConstructor object.
Method used to get a perfectly rounded image. This option is applied after resizing of the image, if any.
- Returns: the current ImagekitUrlConstructor object.
Method used to specify the background color as RGB hex code (e.g. FF0000) or an RGBA code (e.g. FFAABB50) to be used for the image.
-
Parameters:
backgroundColor
— Default value - Black 000000 - Returns: the current ImagekitUrlConstructor object.
Method used to specify the width and color of the border that is added around the image. The width is a positive integer that specifies the border width in pixels. The border color is specified as a standard RGB hex code e.g b-{width}_{color}
-
Parameters:
-
borderWidth
— width of the border -
borderColor
— color of the border as RGB hex code
-
- Returns: the current ImagekitUrlConstructor object.
Method used to automatically enhance the contrast of the image by using the full range of intensity values that a particular image format allows. This basically means that the lighter portions of the image would become even lighter and the darker portions of the image would become even brighter, thereby enhancing the contrast.
-
Parameters:
flag
— - Returns: the current ImagekitUrlConstructor object.
Method sharpens the input image. It is useful to highlight the edges and finer details in the image. If just e-sharpen is used, then a default sharpening is performed on the image. This behavior can be controlled by specifying a number that controls the extent of sharpening performed - higher the number, more the sharpening
-
Parameters:
value
— - Returns: the current ImagekitUrlConstructor object.
fun effectUSM( radius: Float, sigma: Float, amount: Float, threshold: Float ): ImagekitUrlConstructor
Unsharp masking (USM) is an image sharpening technique. Method allows you to apply and control unsharp mask on your images. The amount of sharpening can be controlled by varying the 4 parameters - radius, sigma, amount and threshold. This results in perceptually better images compared to just e-sharpen.
-
Parameters:
-
radius
— Possible values include positive floating point values. -
sigma
— Possible values include positive floating point values. -
amount
— Possible values include positive floating point values. -
threshold
— Possible values include positive floating point values.
-
- Returns: the current ImagekitUrlConstructor object.
Some transformations are dependent on the sequence in which they are carried out. Method used to add sequence dependent steps in a transform chain to obtain predictable results.
- Returns: the current ImagekitUrlConstructor object.
Method allows adding custom transformations to the image.
- Returns: the current ImagekitUrlConstructor object.
Used to create the url using the transformations specified before invoking this method.
- Returns: the Url used to fetch an image after applying the specified transformations.