Skip to content

Commit ae56896

Browse files
authored
Merge pull request #145 from imagekit-developer/SDK-94
added parameters
2 parents 08b4270 + 4b16cdb commit ae56896

File tree

10 files changed

+3792
-4516
lines changed

10 files changed

+3792
-4516
lines changed

README.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,20 @@ ImageKit React SDK allows you to resize, optimize, deliver, and upload images an
1212

1313
ImageKit is a complete media storage, optimization, and transformation solution that comes with an image and video CDN. It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes.
1414

15-
## Breaking changes - Upgrading from 2.x to 3.x version
15+
## Breaking changes
16+
17+
### Upgrading from 3.x to 4.x version
18+
19+
1. Overlay syntax update
20+
21+
* In version 4.0.0, we've removed the old overlay syntax parameters for transformations, such as `oi`, `ot`, `obg`, and [more](https://docs.imagekit.io/features/image-transformations/overlay). These parameters are deprecated and will start returning errors when used in URLs. Please migrate to the new layers syntax that supports overlay nesting, provides better positional control, and allows more transformations at the layer level. You can start with [examples](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#examples) to learn quickly.
22+
* You can migrate to the new layers syntax using the `raw` transformation parameter.
23+
24+
2. IKContext props update
25+
26+
* `IKContext` has been updated to only include `urlEndpoint`, `publicKey`, `authenticator`, and `transformationPosition` props, removing others that were more specific to image, video, and upload, and not typically set globally..
27+
28+
### Upgrading from 2.x to 3.x version
1629
3.x version has breaking changes as listed below.
1730
* In version 3.0.0, we have deprecated the use of the `authenticationEndpoint` parameter. Instead, the SDK now introduces a new parameter named `authenticator`. This parameter expects an asynchronous function that resolves with an object containing the necessary security parameters i.e `signature`, `token`, and `expire`.
1831
* Now `ref` needs to be passed instead of `inputRef` in the IKUpload component
@@ -169,6 +182,15 @@ import { IKImage, IKVideo, IKContext, IKUpload } from 'imagekitio-react'
169182
folder={"/sample-folder"}
170183
ref={uploadRef}
171184
onError={onError} onSuccess={onSuccess}
185+
transformation={{
186+
pre: 'l-text,i-Imagekit,fs-50,l-end',
187+
post: [
188+
{
189+
'type': 'transformation',
190+
'value': 'w-100'
191+
}
192+
]
193+
}}
172194
/>
173195
</IKContext>
174196
```
@@ -333,6 +355,29 @@ For example:
333355
https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end/img/sample-video.mp4
334356
```
335357

358+
359+
### Arithmetic expressions in transformations
360+
361+
ImageKit allows use of [arithmetic expressions](https://docs.imagekit.io/features/arithmetic-expressions-in-transformations) in certain dimension and position-related parameters, making media transformations more flexible and dynamic.
362+
363+
For example:
364+
365+
```js
366+
<IKImage
367+
path="/default-image.jpg"
368+
transformation={[{
369+
"height": "ih_div_2",
370+
"width": "iw_div_4",
371+
"border": "cw_mul_0.05_yellow"
372+
}]}
373+
/>
374+
```
375+
376+
**Sample Result URL**
377+
```
378+
https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=w-iw_div_4,h-ih_div_2,b-cw_mul_0.05_yellow
379+
```
380+
336381
### List of supported transformations
337382
<details>
338383
<summary>Expand</summary>
@@ -366,6 +411,8 @@ https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-ik_canvas,bg-FF
366411
| effectUSM | e-usm |
367412
| effectContrast | e-contrast |
368413
| effectGray | e-grayscale |
414+
| effectShadow | e-shadow |
415+
| effectGradient | e-gradient |
369416
| original | orig |
370417
| raw | The string provided in raw will be added to the URL as it is. |
371418

@@ -603,6 +650,15 @@ const onSuccess = (res) => {
603650
onSuccess={onSuccess}
604651
onUploadStart={onUploadStart}
605652
onUploadProgress={onUploadProgress}
653+
transformation={{
654+
pre: 'l-text,i-Imagekit,fs-50,l-end',
655+
post: [
656+
{
657+
'type': 'transformation',
658+
'value': 'w-100'
659+
}
660+
]
661+
}}
606662
/>
607663
</IKContext>;
608664
```
@@ -633,6 +689,15 @@ const onSuccess = (res) => {
633689
onSuccess={onSuccess}
634690
ref={reftest}
635691
style={{display: 'none'}} // hide default button
692+
transformation={{
693+
pre: 'l-text,i-Imagekit,fs-50,l-end',
694+
post: [
695+
{
696+
'type': 'transformation',
697+
'value': 'w-100'
698+
}
699+
]
700+
}}
636701
/>
637702
<h1>Custom Upload Button</h1>
638703
{reftest && <button className='custom-button-style' onClick={() => reftest.current.click()}>Upload</button>}

0 commit comments

Comments
 (0)