Skip to content

Commit 0b5b567

Browse files
authored
Merge pull request #100 from imagekit-developer/SDK-94
added parameters
2 parents d94e13c + aed5403 commit 0b5b567

File tree

6 files changed

+154
-67
lines changed

6 files changed

+154
-67
lines changed

README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ ImageKit Angular SDK allows you to resize, optimize, deliver, and upload images
1111

1212
ImageKit is 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.
1313

14-
## Breaking changes - Upgrading from 2.x to 3.x version
14+
## Breaking changes
15+
16+
### Upgrading from 3.x to 4.x version
17+
18+
1. Overlay syntax update
19+
20+
* 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.
21+
* You can migrate to the new layers syntax using the `raw` transformation parameter.
22+
23+
### Upgrading from 2.x to 3.x version
24+
1525
3.x version has breaking changes as listed below.
1626
* 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`.
1727

@@ -184,6 +194,15 @@ To use the SDK, you need to provide it with a few configuration parameters. The
184194
[onUploadStart]="onUploadStartFunction"
185195
[onUploadProgress]="onUploadProgressFunction"
186196
[authenticator]="authenticator"
197+
[transformation]="{
198+
'pre': 'l-text,i-Imagekit,fs-50,l-end',
199+
'post': [
200+
{
201+
'type': 'transformation',
202+
'value': 'w-100'
203+
}
204+
]
205+
}"
187206
></ik-upload>
188207
```
189208

@@ -341,6 +360,8 @@ https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-ik_canvas,bg-FF
341360
| effectUSM | e-usm |
342361
| effectContrast | e-contrast |
343362
| effectGray | e-grayscale |
363+
| effectShadow | e-shadow |
364+
| effectGradient | e-gradient |
344365
| original | orig |
345366
| raw | The string provided in raw will be added to the URL as it is. |
346367

@@ -437,6 +458,30 @@ You can lazy-load the original image only when the user scrolls near them. Until
437458
</ik-image>
438459
```
439460

461+
### Arithmetic expressions in transformations
462+
463+
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.
464+
465+
For example:
466+
467+
```js
468+
<ik-image
469+
path="/default-image.jpg"
470+
loading= "lazy"
471+
[transformation]='[{
472+
"height": "ih_div_2",
473+
"width": "iw_div_4",
474+
"border": "cw_mul_0.05_yellow"
475+
}]'
476+
>
477+
</ik-image>
478+
```
479+
480+
**Sample Result URL**
481+
```
482+
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
483+
```
484+
440485
## ik-video
441486

442487
The `ik-video` component renders a `video` tag. It is used for rendering and manipulating videos in real time. `ik-video` component accepts the following props:
@@ -554,6 +599,15 @@ validateFileFunction(res: File) {
554599
[validateFile]="validateFileFunction"
555600
[onUploadStart]="onUploadStartFunction"
556601
[onUploadProgress]="onUploadProgressFunction"
602+
[transformation]="{
603+
'pre': 'l-text,i-Imagekit,fs-50,l-end',
604+
'post': [
605+
{
606+
'type': 'transformation',
607+
'value': 'w-100'
608+
}
609+
]
610+
}"
557611
>
558612
</ik-upload>
559613
```
@@ -570,6 +624,15 @@ Custom button example, using buttonRef
570624
[onUploadStart]="onUploadStartFunction"
571625
[onUploadProgress]="onUploadProgressFunction"
572626
[buttonRef]="myBtn"
627+
[transformation]="{
628+
'pre': 'l-text,i-Imagekit,fs-50,l-end',
629+
'post': [
630+
{
631+
'type': 'transformation',
632+
'value': 'w-100'
633+
}
634+
]
635+
}"
573636
>
574637
</ik-upload>
575638

@@ -599,6 +662,15 @@ onAbortFunction(){
599662
[onUploadStart]="onUploadStartFunction"
600663
[onUploadProgress]="onUploadProgressFunction"
601664
[authenticator]="authenticator"
665+
[transformation]="{
666+
'pre': 'l-text,i-Imagekit,fs-50,l-end',
667+
'post': [
668+
{
669+
'type': 'transformation',
670+
'value': 'w-100'
671+
}
672+
]
673+
}"
602674
></ik-upload>
603675
<button
604676
(click)="onAbortFunction()"

sdk/lib/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "imagekitio-angular",
3-
"version": "3.0.0",
3+
"version": "4.0.0",
44
"author": "ImageKit",
55
"license": "MIT",
66
"private": false,
77
"dependencies": {
8-
"imagekit-javascript": "^2.0.0"
8+
"imagekit-javascript": "^3.0.0"
99
},
1010
"ngPackage": {
1111
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",

sdk/lib/src/imagekitio-angular/ik-upload/ik-upload.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class IkUploadComponent implements AfterViewInit {
3737
@Input('validateFile') validateFile: (file: File) => boolean;
3838
@Input('onUploadStart') onUploadStart: (e: HTMLInputEvent) => void;
3939
@Input('onUploadProgress') onUploadProgress: (e: ProgressEvent) => void;
40+
@Input('transformation') transformation: Object; //optional
4041
fileToUpload: File = null;
4142
xhr: XMLHttpRequest;
4243

@@ -74,7 +75,8 @@ export class IkUploadComponent implements AfterViewInit {
7475
extensions: this.extensions,
7576
webhookUrl: this.webhookUrl,
7677
onError: this.onError,
77-
onSuccess: this.onSuccess
78+
onSuccess: this.onSuccess,
79+
transformation: this.transformation,
7880
}
7981

8082
// Custom validation
@@ -245,6 +247,10 @@ export class IkUploadComponent implements AfterViewInit {
245247
if (options.xhr !== undefined) {
246248
Object.assign(params, { xhr: options.xhr });
247249
}
250+
251+
if (options.transformation !== undefined) {
252+
Object.assign(params, { transformation: options.transformation });
253+
}
248254
return params;
249255
}
250256
}

sdk/lib/src/imagekitio-angular/utility/ik-type-def-collection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ export interface IkUploadComponentOptions {
5454
onSuccess?: EventEmitter<any>;
5555
validateFile?: Function;
5656
xhr?: XMLHttpRequest;
57+
transformation?: Object;
5758
}

0 commit comments

Comments
 (0)