From 601cd6d06f0f28328976336ad518ddb97aace557 Mon Sep 17 00:00:00 2001 From: Lynh Date: Fri, 31 Jan 2025 09:50:03 +0700 Subject: [PATCH] fix: update imagekit crop options and add crop mode --- src/providers/imagekit.test.ts | 5 +++-- src/providers/imagekit.ts | 14 +++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/providers/imagekit.test.ts b/src/providers/imagekit.test.ts index 1ddb834..5d801b7 100644 --- a/src/providers/imagekit.test.ts +++ b/src/providers/imagekit.test.ts @@ -130,7 +130,8 @@ Deno.test("imagekit generate", async (t) => { const result = generate(img, { w: 400, h: 300, - c: "pad_resize", + cm: "pad_resize", + c: "at_max_enlarge", fo: "bottom", bg: "FFFFFF", r: 90, @@ -138,7 +139,7 @@ Deno.test("imagekit generate", async (t) => { }); assertEqualIgnoringQueryOrder( result, - `${img}?tr=w-400,h-300,c-pad_resize,fo-bottom,bg-FFFFFF,r-90,q-85`, + `${img}?tr=w-400,h-300,cm-pad_resize,c-at_max_enlarge,fo-bottom,bg-FFFFFF,r-90,q-85`, ); }, ); diff --git a/src/providers/imagekit.ts b/src/providers/imagekit.ts index fd044d9..baa8fcc 100644 --- a/src/providers/imagekit.ts +++ b/src/providers/imagekit.ts @@ -32,16 +32,24 @@ export interface ImageKitOperations extends Operations { /** * Crop strategy for the image. - * Options: 'maintain_ratio', 'extract', 'pad_resize', 'force', 'at_max', 'at_least' + * Options: 'maintain_ratio', 'force', 'at_max', 'at_max_enlarge', 'at_least' */ c?: | "maintain_ratio" - | "extract" - | "pad_resize" | "force" | "at_max" + | "at_max_enlarge" | "at_least"; + /** + * Crop mode for the image. + * Options: 'extract', 'pad_resize', 'pad_extract' + */ + cm?: + | "extract" + | "pad_resize" + | "pad_extract"; + /** * Focal point for cropping. Can also pass object types for smart cropping. * @see https://imagekit.io/docs/image-resize-and-crop#supported-object-list