Skip to content

Commit e3b688e

Browse files
committed
support raw transformation string
1 parent 76eab3d commit e3b688e

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400/default-image.jpg?v=123&i
173173

174174
See the complete list of transformations supported in ImageKit [here](https://docs.imagekit.io/features/image-transformations). The SDK gives a name to each transformation parameter e.g. `height` for `h` and `width` for `w` parameter. It makes your code more readable. If the property does not match any of the following supported options, it is added as it is.
175175

176+
If you want to generate transformations in your application and add them to the URL as it is, use the `raw` parameter.
177+
176178
| Supported Transformation Name | Translates to parameter |
177179
|-------------------------------|-------------------------|
178180
| height | h |
@@ -232,6 +234,7 @@ See the complete list of transformations supported in ImageKit [here](https://do
232234
| effectContrast | e-contrast |
233235
| effectGray | e-grayscale |
234236
| original | orig |
237+
| raw | `replaced by the parameter value` |
235238

236239

237240

libs/url/builder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import transformationUtils from "../../utils/transformation";
1212
import urlFormatter from "../../utils/urlFormatter";
1313

1414
/*
15-
Interfaces
15+
Interfaces
1616
*/
1717
import { FinalUrlOptions, Transformation } from "../interfaces";
1818

@@ -129,6 +129,8 @@ function constructTransformationString(transformation: Array<Transformation> | u
129129

130130
if (transformation[i][key] === "-") {
131131
parsedTransformStep.push(transformKey);
132+
} else if (key === "raw") {
133+
parsedTransformStep.push(transformation[i][key]);
132134
} else {
133135
var value = String(transformation[i][key]);
134136
if (transformKey === "oi" || transformKey === "di") {

tests/url-generation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,12 @@ describe("URL generation", function () {
298298
effectContrast: true,
299299
effectGray: true,
300300
original: true,
301+
raw: "h-200,w-300,l-image,i-logo.png,l-end",
301302
overlayImageFocus: "face"
302303
}]
303304
})
304305

305-
expect(url).equal(`https://ik.imagekit.io/test_url_endpoint/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,ox-35,oy-35,ofo-bottom,oh-20,ow-20,oi-folder@@file.jpg,oit-false,oiar-4:3,oibg-0F0F0F,oib-10_0F0F0F,oidpr-2,oiq-50,oic-force,ot-two words,ots-20,otf-Open Sans,otc-00FFFF,oa-5,ott-b,obg-00AAFF55,ote-b3ZlcmxheSBtYWRlIGVhc3k%3D,otw-50,otbg-00AAFF55,otp-40,otia-left,or-10,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,orig-true,oifo-face/test_path.jpg`);
306+
expect(url).equal(`https://ik.imagekit.io/test_url_endpoint/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,ox-35,oy-35,ofo-bottom,oh-20,ow-20,oi-folder@@file.jpg,oit-false,oiar-4:3,oibg-0F0F0F,oib-10_0F0F0F,oidpr-2,oiq-50,oic-force,ot-two words,ots-20,otf-Open Sans,otc-00FFFF,oa-5,ott-b,obg-00AAFF55,ote-b3ZlcmxheSBtYWRlIGVhc3k%3D,otw-50,otbg-00AAFF55,otp-40,otia-left,or-10,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,orig-true,h-200,w-300,l-image,i-logo.png,l-end,oifo-face/test_path.jpg`);
306307
});
307308
});
308309

0 commit comments

Comments
 (0)