Last update:2023-10-17 18:18:09
Integrated to CDN architecture, image processing service provides a one-stop image processing solution that includes format conversion, cropping, scaling, rotating, watermarking, etc. This service saves customers from image processing and reduces the ratio of back-to-origin requests. Besides, by outputting the adaptive content with high-reliability via the proximate CDN network, the speed of pages visiting is increased.
Note: Some image-related services can be customized by URL rewriting. For example, there is a CDNetworks customer who was using another CDN vendor’s image optimization feature, which has parameters that are different from that of CDNetworks. And CDNetworks supports rewriting the URL by default, without changing customers usage operations. Please contact CDNetworks CSE for details.
Image processing service includes compression, cropping, scaling, rotation, format conversion, gray scaling, watermarking, image information obtaining, etc. It supports simultaneous enabling of most operation parameters corresponding to different functions. And those parameters that do not support concurrent operations, such as file information obtaining parameters, will take effect by separate steps.
The image processing is made by an image processing server based on the parameters from the image request url. The formats of parameters from the url are fixed, which can be divided into two levels: For level-one parameters, “&” is the separator, “=” assigns the value, and the keywords are {q, Q, crop, resize, r, o, f, g, watermark, info}. For level-two parameters, “,” is the separator, “_” assigns the value, and the keywords are {p, w, h, x, y, a, g, s, e, t, r, s, image, text, d, front, color, size, bc, bs}. When a request is configured for image processing, these keywords in parameters are regarded as the image processing parameters. With the combination of multiple parameters, complex image processing can be realized to meet various user requirements of different scenarios.
Absolute quality |
Compress the original image with q. If the original image quality is 90% and q=80, then a new image at 80% quality is generated. |
Relative quality |
Compress the original image with Q. If the original image quality is 90% and Q=80, then a new image at 72% quality is generated. |
Level-one parameter |
Level-two parameter |
Parameter value |
Operation description |
Value range |
crop= |
p_ |
0 |
Anchor point cropping Set the anchor coordinate (x, y) in the top left corner of the original image, and crop the image with the specified width and height in pixel (w,h). When the specified height (or width) is equal to 0 or the width (or height) counting from the starting point exceeds the original image, it is directly cropped to the end of the original image. If the starting points exceed the original image, return the original image. Example: start from coordinate x_50, y_50, crop a 400*200 image http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?crop=p_0, x_50,y_50,w_400,h_200 |
w,h value range:[0, +∞) |
1 |
Center cropping Take the center of the original image as the image center, and crop out an image with the specified width and height in pixel (w,h). When either w or h is invalid, return the original image. Example: take the original image center as the cropping center, and crop out a 400*200 image http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?crop=p_1,w_400,h_200 Note: corresponding old parameters, p=4 |
w,h value≥0 |
||
2 |
Gravity center cropping Use parameter g to set the position of nine-rectangle-grid, and crop an image with specified width and height in pixel (w,h) after offsetting x and y. When either w or h is invalid, return the original image. Example: start from southeast, crop a 400*200 image http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?crop=p_2,w_400,h_200,g_se |
x,y value≥0, the default is 0; w,h value≥0; g value range: [nw,north,ne,west,center,east,sw,south,se]. |
||
3 |
Index cropping Crop the x axis (y axis) of the original image at the specified length, and then get the image within the area with specific index. The length range is [1, length of the cropped side]. If the input length exceeds the cropped side, return the original image. The principle also applies in index cropping when the input index exceeds the maximum. Example: crop y axis with the length of 100, and crop out the image within the corresponding area with specified index 2 http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?crop=p_2,i_2,y_100 |
x,y value≥0, default is 0; w,h value≥0; i value≥0, default is 0. |
||
4 |
Inscribed circle Show the original image in a circle shape If the final image format is png, webp or other formats that support transparency (also known as Alpha channel), then fill the non-circle area with transparency. If the final image format is jpg, fill the non-circle area with white. Value range: r value is larger than 0; inscribed circle and scaling can be effective at the same time. http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?crop=p_4,r_200 |
r value≥0 |
||
6 |
square_enlarge cropping When the parameter s is 1, crop a square with the shorter side of the original image being the square side. When the parameters e and s are 1, enlarge the square using the longer side of the original image. For example: enlarge the square with the longer side of the original image being the square side. http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?crop=p_6,s_1,e_1 |
s value range is0-1, no default value; e value range is 0-1, no default value. |
||
7 |
extend cropping (value of t is 1) When the requested width and height are greater than that of the original image, center the original image and fill the surrounding with white; When the requested width and height are smaller than that of the original image, center crop the image; When the requested width is larger than that of the original image, and height is smaller, center crop the image and fill both left and right sides with white; When the requested width is smaller than that of the original image, and height is larger, center crop the image and fill both top and bottom sides with white; For example: the size of original image is 640x354, and the requested size is 700x500, center crop the original image and fill the surrounding with white. http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?crop=p_7,w_700,h_500 |
|
||
|
9 |
Percentage cropping w, h: indicates that the width and height of thumbnail are w%W and h%H, and the value range is [1, 1000]; When w and h are specified, the image with the size of width and height in pixel (w%W, h%H) will be cropped from the start point of the original image; When w is specified, the image with the size of width and height in pixel (w%W, w%H) will be cropped from the start point of the original image; When h is specified, the image with the size of width and height in pixel (h%W, h%H) will be cropped from the start point of the original image. x,y: are the start anchor coordinates; When x,y are specified, the anchor coordinates are (x,y); When x is specified, anchor coordinate is (x, (H-h)/2); When y is specified, anchor coordinate is ((W-w)/2, y); Note: w and h are the width and height in pixel after percentage calculation; For example: crop an image with 50% width and 70% height of the original image. http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?crop=p_9,w_50,h_70 |
w,h value range is [1, 1000]; x,y value range is [0, +∞). |
|
|
10 |
Gravity center cropping after scaling Scale down the original image, and the width and height of the re-sized image are larger or equal to w*h; Crop by specified g, and a thumbnail image of w*h will be obtained; When w or h is larger than that of the original image, the corresponding value of the original image is adopted; When w or h equals to 0, make the proportional scaling with the other side; For example: resize the original image with the proportion of 300x70, and adopt the upper part of gravity center |
w,h cannot both be 0; w,h value [0, +∞) |
|
x,y |
x-coordinate value, y-coordinate value |
|
|
|
w,h |
Width, height value |
|
|
|
g |
[nw,north,ne,west,center,east,sw,south,se] |
Use parameter g to set the position of the nine-rectangle-grid |
Default is se |
|
i |
Specify index block |
After cropping into designated length, specify the index |
Default is 0 |
|
s,e |
0 or 1 |
Crop by a specified method |
|
|
t |
0 or 1 |
Crop by a specified method |
|
Level-one parameter |
Level-two parameter |
Parameter value |
Operation description |
Value range |
resize= |
p_ |
0 |
Stretch the original image following w*h pixel. If there is no w*h value, use that of the original image. Parameters of w and h must coexist, otherwise the original image will be returned Example: stretch the original image, and the width and height in pixel is 500*200 http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?resize=p_0,w_500,h_200 Note: corresponding old parameter p=0 |
w,h value range is [1-10000] |
1 |
Percentage scaling Resize the width and height of the original image by a percentage For example: scale down the width to 50% of the original, and height to 50% of the original http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?resize=p_1,w_50,h_50; Note: corresponding old parameter p=5 |
w,h value range is [1-1000] |
||
2 |
Filling after scaling Set w and h, scale the original image proportionally. Thewidth and height should not surpass w*h. Center the re-sized image and fill the empty part with color. When either w or h is invalid, return the original image. Example: scale down the original image to 200*200 and fill in the empty space with white http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?resize=p_2,w_200,h_200; |
w,h value range is [1-10000]; Color supports hexadecimal, and the default is #ffffff(white) |
||
3 |
Cropping after scaling 1) Specify w and h: scale down proportionally, and then crop the part that exceeds w*h, and the processed image is w*h. 2) Only specify w: if w is smaller than width and height, then scale down first before cropping, the processed image is w*w; If w is smaller than width while greater than height, then crop the image, and the processed image is w*height; If w is greater than width but smaller than height, then crop the image, and the processed image is width*w; If w is greater than width and height, the original image will be returned 3) Only specify h: if h is smaller than width and height at the same time, then scale down first before cropping, and the processed size is h*h; if h is smaller than width while greater than height, then crop the image, the processed size is h*height; if h is greater than width but smaller than height, then crop the image, and the processed size is width*h; if h is greater than width and height, return the original image Example: scale down the original image, and the size of the processed image is 300*200 http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?resize=p_3,w_300,h_200; Note: Corresponding old parameter p=1 |
w,h value range is [1-10000] |
||
4 |
Scale down proportionally, and the width and height should not surpass w*h Specify w and h: width is w, scale down height proportionally; height is h, scale down the width proportionally. It is correct when the width and height do not surpass w*h 2) Only specify w: w for width, scale down height proportionally 3) Only specify h: h for height, scale down width proportionally Note: corresponding old parameter p=2 |
w,h value range is [1-10000] |
||
5 |
Scale down proportionally, and width and height should be no smaller than w*h 1) Specify w and h: width is w, scale down width proportionally; height is h, scale down the height proportionally, and the correct result is that width and height are no smaller than w*h 2) Only specify w: when width is w, scale down height proportionally 3) Only specify h: when height is h, scale down width proportionally Note: corresponding old parameter p=3 |
w,h value range is [1-10000] |
||
6 |
Scale up proportionally, and if both w and h are smaller than that of the original image, width and height cannot surpass w*h 1) If width of the original image is smaller than the given w, and height of the original image is greater than the specified h, return the original image 2) If width of the original image is greater than the given w, and height of the original image is smaller than the specified h, return the original image 3) If the width of the original image is greater than the given w, and the height of the original image is greater than the specified h, scale the image according to the given w, h proportionally. Only adopt the values that do not exceed w, h. Note: corresponding old parameter is p=8 |
w,h value range is [1-10000] |
||
7 |
Proportional scaling, and the pixel should not exceed the specified value Make the proportional scaling of the original image, and the value of width*height shall not exceed the pixel value of the specified area. Example: specify 10000 as the pixel value, and make the proportional scaling of the image http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?resize=p_7,a_10000 or: http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?resize=a_10000; Note: old parameters, a |
a value range is [1-24999999] |
||
|
8 |
Width and height limit When the requested image is larger than a certain width and height, make the proportional scaling; the width and height of thumbnail image should be smaller or equal to the specified; or there will be no processing; When w and h are specified, and the width and height of the original are smaller than the specified value, there will be no processing; otherwise, there will be proportional scaling down, and the width and height of thumbnail are smaller or equal to w*h; When w is specified, and the width of the original is smaller than the specified value, there will be no processing; otherwise, there will be proportional scaling down with according to w; When h is specified, and the height of the original is smaller than the specified value, there will be no processing; otherwise, there will be proportional scaling down according to h; |
w,h value range is [1-10000] |
|
w,h |
Width, height |
When value range of p is 0,2,3,4,5, w and h specify the width and height of the thumbnail |
|
|
color |
Color code |
For color code, only hexadecimal value starts with # is supported |
Default is #ffffff(white) |
|
a |
Width*height |
When the value range of p is 7, scale the image proportionally and pixel of width*height should not exceed the a-specified pixel |
A value range is [1-24999999] |
Level-one parameter |
Level-two parameter |
Parameters and operation description |
watermark= |
m_ |
Modes of watermark processing 0: no watermarking processing, default value; 1. Image watermarking; 2. Text watermarking; 3. Mixed watermarking, image under text; 4. Mixed watermarking, text under image; |
image_ |
Base64 encoding, support pre-processing of watermark image |
|
text_ |
Base64 encoding |
|
d_ |
Watermark transparency, value range: 0-100 |
|
g_ |
Watermark position, value range: [nw,north,ne,west,center,east,sw,south,se] |
|
dx_ |
Offset on X-axis, value range is [1,+∞), default value is 10, unit: pixel |
|
dy_ |
Offset on Y-axis, value range is [1,+∞),default value is 10, unit: pixel |
|
font_ |
Font of text watermark, base64 encoding |
|
color_ |
Color of watermark text, with white as the default value. More options:”blue”, “#0000ff”, “rgb (0,0,255)”, base 64 encoding |
|
size_ |
Font size of text watermark, value range is (0,1000], default value is 30 |
|
r_ |
Rotation of text watermark, value range is [0,360], default value is 0 |
|
bc_ |
Outlined color of the watermark text, base64 encoding |
|
bs_ |
Outlined thickness of the watermark text, range value is (0, 50), default value is 1, suggested value is 0.5-2 |
Level-two parameter |
Description |
Value |
r |
Radius of Gaussian blur |
Value range is 1-50 |
s |
standard deviation of the Gaussian distribution |
Value range is 1-50 |
(3) Example:
http://images.demo.cdnetworks.com/ctuU-fxriqqx2975432.jpg?blur=r_2,s_4