This specification outlines the details for an image processing API, including resizing, formatting, effects, and image delivery.
The API processes images via URL query parameters, supporting operations like resizing, format conversion, quality adjustments, and effects such as blurring.
Base URL:
https://api.example.com/v1/image
-
w
(Width):- Description: Sets the output image width in pixels.
- Type: Integer.
- Default: Original image width.
- Example:
w=300
. - Reference: Image Width.
-
h
(Height):- Description: Sets the output image height in pixels.
- Type: Integer.
- Default: Original image height.
- Example:
h=200
. - Reference: Image Height.
-
fit
(Resize Mode):- Description: Specifies how the image should be resized to fit the given dimensions.
- Type: Enum (
clip
,crop
,fill
). - Default:
clip
. - Example:
fit=crop
. - Reference: Resize Fit Mode.
-
dpr
(Device Pixel Ratio):- Description: Adjusts the resolution for high-density displays (e.g., Retina screens).
- Type: Float (1.0–3.0).
- Default: 1.0.
- Example:
dpr=2
. - Reference: Device Pixel Ratio.
-
fm
(Format):- Description: Specifies the output format of the image.
- Type: Enum (
jpg
,png
,webp
). - Default: Retains the original format.
- Example:
fm=webp
. - Reference: Output Format.
-
q
(Quality):- Description: Adjusts the compression quality for supported formats.
- Type: Integer (0–100).
- Default: 80.
- Example:
q=80
. - Reference: Output Quality.
blur
(Gaussian Blur):- Description: Applies a blur effect to the image.
- Type: Integer (0–100).
- Default: 0 (no blur).
- Example:
blur=15
. - Reference: Gaussian Blur.
dl
(Force Download):- Description: Forces the image to be downloaded instead of displayed.
- Type: Boolean (
1
for true). - Default:
false
. - Example:
dl=1
.
https://api.example.com/v1/image?url=https://example.com/image.jpg?w=300&h=200&fit=crop
https://api.example.com/v1/image?url=https://example.com/image.jpg?fm=webp&q=80
https://api.example.com/v1/image?url=https://example.com/image.jpg?blur=15&dpr=2
https://api.example.com/v1/image?url=https://example.com/image.jpg?dl=1
- Success: Returns the processed image.
- HTTP Status:
200 OK
. - Content-Type: Depends on the
fm
parameter (image/jpeg
,image/png
,image/webp
).
- HTTP Status:
- Error:
- HTTP Status:
400 Bad Request
(invalid parameters). - HTTP Status:
404 Not Found
(image not found).
- HTTP Status: