Skip to content

Commit 737e596

Browse files
committed
JS SDK Commit 1
0 parents  commit 737e596

File tree

16 files changed

+24125
-0
lines changed

16 files changed

+24125
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/*

Gruntfile.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = function(grunt) {
2+
3+
// Project configuration.
4+
grunt.initConfig({
5+
pkg: grunt.file.readJSON('package.json'),
6+
browserify: {
7+
dist : {
8+
files : {
9+
'dist/imagekit.js' : ['index.js']
10+
},
11+
options : {
12+
browserifyOptions : {
13+
"standalone" : "ImageKit"
14+
}
15+
}
16+
}
17+
}
18+
});
19+
20+
grunt.loadNpmTasks('grunt-browserify');
21+
22+
// Default task(s).
23+
grunt.registerTask('default', ['browserify:dist']);
24+
25+
};
26+

constants/errorMessages.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
"MANDATORY_INITIALIZATION_MISSING" : { message : "Missing publicKey or privateKey or urlEndpoint during ImageKit initialization", help : "" },
3+
"INVALID_TRANSFORMATION_POSITION" : { message : "Invalid transformationPosition parameter", help : "" },
4+
"PRIVATE_KEY_CLIENT_SIDE" : { message : "privateKey should not be passed on the client side", help : "" },
5+
"MISSING_UPLOAD_DATA" : { message : "Missing data for upload", help : "" },
6+
"MISSING_UPLOAD_FILE_PARAMETER" : { message : "Missing file parameter for upload", help : "" },
7+
"MISSING_UPLOAD_FILENAME_PARAMETER" : { message : "Missing fileName parameter for upload", help : "" },
8+
"MISSING_AUTHENTICATION_ENDPOINT" : { message : "Missing authentication endpoint for upload", help : "" }
9+
}

constants/supportedTransforms.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
"HEIGHT" : "h",
3+
"WIDTH" : "w",
4+
"ASPECT_RATIO" : "ar",
5+
"QUALITY" : "q",
6+
"CROP" : "c",
7+
"CROP_MODE" : "cm",
8+
"X" : "x",
9+
"Y" : "y",
10+
"FOCUS" : "fo",
11+
"FORMAT" : "f",
12+
"RADIUS" : "r",
13+
"BACKGROUND" : "bg",
14+
"BORDER" : "bo",
15+
"ROTATION" : "rt",
16+
"BLUR" : "bl",
17+
"NAMED" : "n",
18+
"OVERLAY_IMAGE" : "oi",
19+
"OVERLAY_X" : "ox",
20+
"OVERLAY_Y" : "oy",
21+
"OVERLAY_FOCUS" : "ofo",
22+
"OVERLAY_HEIGHT" : "oh",
23+
"OVERLAY_WIDTH" : "ow",
24+
"OVERLAY_TEXT" : "ot",
25+
"OVERLAY_TEXT_FONT_SIZE" : "ots",
26+
"OVERLAY_TEXT_FONT_FAMILY" : "otf",
27+
"OVERLAY_TEXT_COLOR" : "otc",
28+
"OVERLAY_ALPHA" : "oa",
29+
"OVERLAY_TEXT_TYPOGRAPHY" : "ott",
30+
"OVERLAY_BACKGROUND" : "obg",
31+
"OVERLAY_IMAGE_TRIM" : "oit",
32+
"PROGRESSIVE" : "pr",
33+
"LOSSLESS" : "lo",
34+
"TRIM" : "t",
35+
"METADATA" : "md",
36+
"COLOR_PROFILE" : "cp",
37+
"DEFAULT_IMAGE" : "di",
38+
"DPR" : "dpr",
39+
"EFFECT_SHARPEN" : "e-sharpen",
40+
"EFFECT_USM" : "e-usm",
41+
"EFFECT_CONTRAST" : "e-contrast",
42+
"EFFECT_GRAY" : "e-grayscale",
43+
"ORIGINAL" : "orig"
44+
};

demo/index.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<html>
2+
3+
<body>
4+
ImageKit Demo
5+
<form action="#" onsubmit="upload()">
6+
<input type="file" id="file1" />
7+
<input type="submit" />
8+
</form>
9+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
10+
<script type="text/javascript" src="../dist/imagekit.js"></script>
11+
<script>
12+
try {
13+
var imagekit = new ImageKit({
14+
publicKey : "your_public_api_key",
15+
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id",
16+
authenticationEndpoint : "http://www.yourserver.com/auth",
17+
});
18+
19+
function upload(data) {
20+
var file = document.getElementById("file1");
21+
imagekit.upload({
22+
file : file.files[0],
23+
fileName : "abc1.jpg",
24+
tags : ["tag1"]
25+
}, function(err, result) {
26+
console.log(arguments);
27+
console.log(imagekit.url({
28+
src: result.url,
29+
transformation : [{ HEIGHT: 300, WIDTH: 400}]
30+
}));
31+
})
32+
}
33+
} catch(ex) {
34+
console.log(ex);
35+
}
36+
</script>
37+
</body>
38+
</html>

0 commit comments

Comments
 (0)