Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8051f61
refactor: improve type safety in transformation string construction a…
manu4543 Mar 18, 2025
8fa1219
refactor: enhance type safety and clarity in Transformation interface
manu4543 Mar 18, 2025
63b01cd
refactor: update transformation interface and supported transforms fo…
manu4543 Mar 18, 2025
95d954e
refactor: enhance transformation string construction and add tests fo…
manu4543 Mar 18, 2025
60447ca
refactor: clean up supportedTransforms and improve type definition fo…
manu4543 Mar 18, 2025
d07979f
chore: bump version to 3.1.0 in package.json and package-lock.json
manu4543 Mar 18, 2025
c96900a
refactor: correct comment to clarify transformation effect applicatio…
manu4543 Mar 18, 2025
91445e0
refactor: standardize property names for transformation interface and…
manu4543 Mar 18, 2025
3cdcc08
refactor: update documentation links to use the correct markdown format
manu4543 Mar 18, 2025
7d7837a
refactor: improve comment clarity for third-party background removal …
manu4543 Mar 18, 2025
0d105fb
Update src/interfaces/Transformation.ts
imagekitio Mar 19, 2025
f9007a2
add test cases
manu4543 Mar 19, 2025
4b123f5
test: add comprehensive URL generation tests for transformation param…
manu4543 Mar 19, 2025
6d72361
update test cases descriptions and one test case
manu4543 Mar 19, 2025
d9fa8ff
fix: handle empty transformation keys in URL construction
manu4543 Mar 19, 2025
40deb6b
chore: add CHANGELOG.md and update README to include changelog reference
manu4543 Mar 19, 2025
ed31f55
update readme
manu4543 Mar 19, 2025
b9e554d
change badge position
manu4543 Mar 19, 2025
02751f3
docs: enhance README with detailed SDK initialization and transformat…
manu4543 Mar 19, 2025
010e9a0
docs: update README with quick demo references and remove outdated in…
manu4543 Mar 19, 2025
2ccfcf2
docs: update README to rename 'Demo Application' section to 'Test Exa…
manu4543 Mar 19, 2025
8b3067d
feat: add static file serving and update image handling in Pug template
manu4543 Mar 19, 2025
7530fd3
docs: update CHANGELOG with corrected links for overlay syntax and fi…
manu4543 Mar 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imagekit-javascript",
"version": "3.0.2",
"version": "3.1.0",
"description": "Javascript SDK for using ImageKit.io in the browser",
"main": "dist/imagekit.cjs.js",
"module": "dist/imagekit.esm.js",
Expand Down
188 changes: 48 additions & 140 deletions src/constants/supportedTransforms.ts
Original file line number Diff line number Diff line change
@@ -1,167 +1,75 @@
/**
* @link https://docs.imagekit.io/features/image-transformations
* {@link https://imagekit.io/docs/transformations}
*/
const supportedTransforms: { [key: string]: string } = {
/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#width-w
*/
export const supportedTransforms: { [key: string]: string } = {
// Basic sizing & layout
width: "w",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#height-h
*/
height: "h",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#aspect-ratio-ar
*/
aspectRatio: "ar",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#quality-q
*/
quality: "q",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#crop-crop-modes-and-focus
*/
background: "bg",
border: "b",
crop: "c",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#crop-crop-modes-and-focus
*/
cropMode: "cm",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#focus-fo
*/
dpr: "dpr",
focus: "fo",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#examples-focus-using-cropped-image-coordinates
*/
quality: "q",
x: "x",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#examples-focus-using-cropped-image-coordinates
*/
xCenter: "xc",
y: "y",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#format-f
*/
yCenter: "yc",
format: "f",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#radius-r
*/
videoCodec: "vc",
audioCodec: "ac",
radius: "r",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#background-color-bg
*/
background: "bg",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#border-b
*/
border: "b",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#rotate-rt
*/
rotation: "rt",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#rotate-rt
*/
rotate: "rt",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#blur-bl
*/
blur: "bl",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#named-transformation-n
*/
named: "n",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#progressive-image-pr
*/
progressive: "pr",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#lossless-webp-and-png-lo
*/
lossless: "lo",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#trim-edges-t
*/
trim: "t",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#image-metadata-md
*/
metadata: "md",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#color-profile-cp
*/
colorProfile: "cp",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#default-image-di
*/
defaultImage: "di",
flip: "fl",
original: "orig",
startOffset: "so",
endOffset: "eo",
duration: "du",
streamingResolutions: "sr",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#dpr-dpr
*/
dpr: "dpr",

/**
* @link https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#sharpen-e-sharpen
*/
// Old deprecated mappings
effectSharpen: "e-sharpen",

/**
* @link https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#unsharp-mask-e-usm
*/
effectUSM: "e-usm",

/**
* @link https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#contrast-stretch-e-contrast
*/
effectContrast: "e-contrast",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#grayscale-e-grayscale
*/
effectGray: "e-grayscale",

/**
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#original-image-orig
*/
original: "orig",

/**
* @link https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#shadow-e-shadow
*/
effectShadow: "e-shadow",

/**
* @link https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#gradient-e-gradient
*/
effectGradient: "e-gradient",
rotate: "rt",

// AI & advanced effects
grayscale: "e-grayscale",
aiBGRemoveExternal: "e-removedotbg",
aiUpscale: "e-upscale",
aiRetouch: "e-retouch",
aiVariation: "e-genvar",
aiDropShadow: "e-dropshadow",
aiChangeBackground: "e-changebg",
aiRemoveBackground: "e-bgremove",
contrastStretch: "e-contrast",
shadow: "e-shadow",
sharpen: "e-sharpen",
unsharpMask: "e-usm",
gradient: "e-gradient",

// Other flags & finishing
progressive: "pr",
lossless: "lo",
colorProfile: "cp",
metadata: "md",
opacity: "o",
trim: "t",
zoom: "z",
page: "pg",

// Raw pass-through
raw: "raw",
};

/**
* @link https://docs.imagekit.io/features/image-transformations/conditional-transformations
*/
raw: "raw",
}


export default supportedTransforms
17 changes: 3 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,16 @@ class ImageKit {
}

/**
* You can add multiple origins in the same ImageKit.io account.
* URL endpoints allow you to configure which origins are accessible through your account and set their preference order as well.
*
* @see {@link https://github.com/imagekit-developer/imagekit-nodejs#url-generation}
* @see {@link https://docs.imagekit.io/integration/url-endpoints}
*
* @param urlOptions
* A utility function to generate asset URL. It applies the specified transformations and other parameters to the URL.
*/
url(urlOptions: UrlOptions): string {
return url(urlOptions, this.options);
}

/**
* You can upload files to ImageKit.io media library from your server-side using private API key authentication.
*
* File size limit
* The maximum upload file size is limited to 25MB.
*
* @see {@link https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload}
* For uploading files directly from the browser to ImageKit.io.
*
* @param uploadOptions
* {@link https://imagekit.io/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload}
*/
upload(uploadOptions: UploadOptions, options?: Partial<ImageKitOptions>): Promise<IKResponse<UploadResponse>>
upload(uploadOptions: UploadOptions, callback: (err: Error | null, response: IKResponse<UploadResponse> | null) => void, options?: Partial<ImageKitOptions>): void;
Expand Down
Loading