Skip to content

Commit 857aa2b

Browse files
authored
Merge pull request #115 from imagekit-developer/feat/colorize-and-crop-modes
Feat/colorize and crop modes
2 parents 2378655 + 952e6e8 commit 857aa2b

6 files changed

Lines changed: 25 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Version 5.4.0
4+
5+
1. **Enhancement:**
6+
- Added support for new crop modes: `maintain_ratio_no_enlarge`, `pad_resize_no_enlarge` and `pad_extract_no_shrink`
7+
- Added support for `colorize` transformation
8+
39
## Version 5.3.0
410

511
1. **Enhancement:**

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@imagekit/javascript",
3-
"version": "5.3.0",
3+
"version": "5.4.0",
44
"description": "ImageKit Javascript SDK",
55
"main": "dist/imagekit.cjs.js",
66
"module": "dist/imagekit.esm.js",

src/constants/supportedTransforms.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const supportedTransforms: { [key: string]: string } = {
4949
gradient: "e-gradient",
5050
colorReplace: "cr",
5151
distort: "e-distort",
52+
colorize: "e-colorize",
5253

5354
// Other flags & finishing
5455
progressive: "pr",

src/interfaces/shared.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,17 @@ export interface Transformation {
14141414
*/
14151415
border?: string;
14161416

1417+
/**
1418+
* Applies a color tint to the image. Accepts color and intensity as optional
1419+
* parameters.
1420+
*
1421+
* - `co-color` - Color to apply (e.g., `red`, `blue`, `FF0022`). Default is gray
1422+
* color.
1423+
* - `in-intensity` - Intensity of the color (0-100). Default is 35. See
1424+
* [Colorize](https://imagekit.io/docs/effects-and-enhancements#colorize---e-colorize).
1425+
*/
1426+
colorize?: string;
1427+
14171428
/**
14181429
* Indicates whether the output image should retain the original color profile. See
14191430
* [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp).
@@ -1442,13 +1453,13 @@ export interface Transformation {
14421453
* Crop modes for image resizing. See
14431454
* [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus).
14441455
*/
1445-
crop?: 'force' | 'at_max' | 'at_max_enlarge' | 'at_least' | 'maintain_ratio';
1456+
crop?: 'force' | 'at_max' | 'at_max_enlarge' | 'at_least' | 'maintain_ratio' | 'maintain_ratio_no_enlarge';
14461457

14471458
/**
14481459
* Additional crop modes for image resizing. See
14491460
* [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus).
14501461
*/
1451-
cropMode?: 'pad_resize' | 'extract' | 'pad_extract';
1462+
cropMode?: 'pad_resize' | 'extract' | 'pad_extract' | 'pad_resize_no_enlarge' | 'pad_extract_no_shrink';
14521463

14531464
/**
14541465
* Specifies a fallback image if the resource is not found, e.g., a URL or file

test/url-generation/basic.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,13 +1279,14 @@ describe("URL generation", function () {
12791279
raw: "h-200,w-300,l-image,i-logo.png,l-end",
12801280
// New transformation parameters
12811281
colorReplace: 'FF0000_50_00FF00',
1282+
colorize: 'co-red_in-35',
12821283
distort: 'p-50_50_150_50_150_150_50_150',
12831284
}
12841285
]
12851286
});
12861287

12871288
expect(url).equal(
1288-
`https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,x-10,y-20,xc-30,yc-40,fl-h,o-0.8,z-2,vc-h264,ac-aac,so-5,eo-15,du-10,sr-1440_1080,e-grayscale,e-upscale,e-retouch,e-genvar,e-dropshadow,e-changebg-prompt-car,e-edit-prompt-make it vintage,e-bgremove,e-contrast,e-shadow-bl-15_st-40_x-10_y-N5,e-sharpen-10,e-usm-2-2-0.8-0.024,e-gradient-from-red_to-white,orig-true,pg-2_4,h-200,w-300,l-image,i-logo.png,l-end,cr-FF0000_50_00FF00,e-distort-p-50_50_150_50_150_150_50_150`
1289+
`https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,x-10,y-20,xc-30,yc-40,fl-h,o-0.8,z-2,vc-h264,ac-aac,so-5,eo-15,du-10,sr-1440_1080,e-grayscale,e-upscale,e-retouch,e-genvar,e-dropshadow,e-changebg-prompt-car,e-edit-prompt-make it vintage,e-bgremove,e-contrast,e-shadow-bl-15_st-40_x-10_y-N5,e-sharpen-10,e-usm-2-2-0.8-0.024,e-gradient-from-red_to-white,orig-true,pg-2_4,h-200,w-300,l-image,i-logo.png,l-end,cr-FF0000_50_00FF00,e-colorize-co-red_in-35,e-distort-p-50_50_150_50_150_150_50_150`
12891290
);
12901291
});
12911292
});

0 commit comments

Comments
 (0)