jimp 0.22.12 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/commonjs/fonts.d.ts +5 -0
  2. package/dist/commonjs/fonts.d.ts.map +1 -0
  3. package/dist/commonjs/fonts.js +21 -0
  4. package/dist/commonjs/fonts.js.map +1 -0
  5. package/dist/commonjs/index.d.ts +324 -0
  6. package/dist/commonjs/index.d.ts.map +1 -0
  7. package/dist/commonjs/index.js +189 -0
  8. package/dist/commonjs/index.js.map +1 -0
  9. package/dist/commonjs/package.json +7 -0
  10. package/dist/esm/fonts.d.ts +5 -0
  11. package/dist/esm/fonts.d.ts.map +1 -0
  12. package/dist/esm/fonts.js +5 -0
  13. package/dist/esm/fonts.js.map +1 -0
  14. package/dist/esm/index.d.ts +324 -0
  15. package/dist/esm/index.d.ts.map +1 -0
  16. package/dist/esm/index.js +163 -0
  17. package/dist/esm/index.js.map +1 -0
  18. package/dist/esm/package.json +7 -0
  19. package/package.json +103 -42
  20. package/README.md +0 -779
  21. package/browser/README.md +0 -67
  22. package/browser/examples/dice.png +0 -0
  23. package/browser/examples/example1.html +0 -25
  24. package/browser/examples/example2.html +0 -20
  25. package/browser/examples/example3.html +0 -31
  26. package/browser/examples/example4.html +0 -74
  27. package/browser/examples/jimp-worker.js +0 -18
  28. package/browser/examples/lenna.png +0 -0
  29. package/browser/examples/test.html +0 -49
  30. package/browser/lib/jimp.js +0 -3
  31. package/browser/lib/jimp.js.LICENSE.txt +0 -277
  32. package/browser/lib/jimp.js.map +0 -1
  33. package/dist/index.js +0 -18
  34. package/dist/index.js.map +0 -1
  35. package/es/index.js +0 -8
  36. package/es/index.js.map +0 -1
  37. package/fonts/open-sans/Apache License.txt +0 -201
  38. package/fonts/open-sans/open-sans-10-black/open-sans-10-black.fnt +0 -160
  39. package/fonts/open-sans/open-sans-10-black/open-sans-10-black.png +0 -0
  40. package/fonts/open-sans/open-sans-12-black/open-sans-12-black.fnt +0 -183
  41. package/fonts/open-sans/open-sans-12-black/open-sans-12-black.png +0 -0
  42. package/fonts/open-sans/open-sans-128-black/open-sans-128-black.fnt +0 -298
  43. package/fonts/open-sans/open-sans-128-black/open-sans-128-black.png +0 -0
  44. package/fonts/open-sans/open-sans-128-white/open-sans-128-white.fnt +0 -298
  45. package/fonts/open-sans/open-sans-128-white/open-sans-128-white.png +0 -0
  46. package/fonts/open-sans/open-sans-14-black/open-sans-14-black.fnt +0 -215
  47. package/fonts/open-sans/open-sans-14-black/open-sans-14-black.png +0 -0
  48. package/fonts/open-sans/open-sans-16-black/open-sans-16-black.fnt +0 -298
  49. package/fonts/open-sans/open-sans-16-black/open-sans-16-black.png +0 -0
  50. package/fonts/open-sans/open-sans-16-white/open-sans-16-white.fnt +0 -298
  51. package/fonts/open-sans/open-sans-16-white/open-sans-16-white.png +0 -0
  52. package/fonts/open-sans/open-sans-32-black/open-sans-32-black.fnt +0 -298
  53. package/fonts/open-sans/open-sans-32-black/open-sans-32-black.png +0 -0
  54. package/fonts/open-sans/open-sans-32-white/open-sans-32-white.fnt +0 -298
  55. package/fonts/open-sans/open-sans-32-white/open-sans-32-white.png +0 -0
  56. package/fonts/open-sans/open-sans-64-black/open-sans-64-black.fnt +0 -298
  57. package/fonts/open-sans/open-sans-64-black/open-sans-64-black.png +0 -0
  58. package/fonts/open-sans/open-sans-64-white/open-sans-64-white.fnt +0 -298
  59. package/fonts/open-sans/open-sans-64-white/open-sans-64-white.png +0 -0
  60. package/fonts/open-sans/open-sans-8-black/open-sans-8-black.fnt +0 -298
  61. package/fonts/open-sans/open-sans-8-black/open-sans-8-black.png +0 -0
  62. package/fonts/open-sans/open-sans-8-white/open-sans-8-white.fnt +0 -298
  63. package/fonts/open-sans/open-sans-8-white/open-sans-8-white.png +0 -0
  64. package/types/index.d.ts +0 -53
  65. package/types/test.ts +0 -95
  66. package/types/tsconfig.json +0 -19
package/browser/README.md DELETED
@@ -1,67 +0,0 @@
1
- # Jimp ... in a browser
2
-
3
- Browser support for Jimp was added by Phil Seaton. This enabled Jimp to be used in [Electron](http://electron.atom.io/) applications as well as web browsers.
4
-
5
- Example usage:
6
-
7
- ```html
8
- <script src="jimp.min.js"></script>
9
- <script>
10
- Jimp.read("lenna.png")
11
- .then(function (lenna) {
12
- lenna
13
- .resize(256, 256) // resize
14
- .quality(60) // set JPEG quality
15
- .greyscale() // set greyscale
16
- .getBase64(Jimp.MIME_JPEG, function (err, src) {
17
- var img = document.createElement("img");
18
- img.setAttribute("src", src);
19
- document.body.appendChild(img);
20
- });
21
- })
22
- .catch(function (err) {
23
- console.error(err);
24
- });
25
- </script>
26
- ```
27
-
28
- See the [main documentation](https://github.com/jimp-dev/jimp) for the full API documenatinon.
29
-
30
- ## WebWorkers
31
-
32
- For better performance, it recommended that Jimp methods are run on a separate thread using [`WebWorkers`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers). The following shows how using two files (`index.html` and `jimp-worker.js`):
33
-
34
- ```js
35
- // index.html
36
-
37
- var worker = new Worker("jimp-worker.js");
38
- worker.onmessage = function (e) {
39
- // append a new img element using the base 64 image
40
- var img = document.createElement("img");
41
- img.setAttribute("src", e.data);
42
- document.body.appendChild(img);
43
- };
44
- worker.postMessage("lenna.png"); // message the worker thread
45
- ```
46
-
47
- ```js
48
- // jimp-worker.js
49
-
50
- importScripts("jimp.min.js");
51
-
52
- self.addEventListener("message", function (e) {
53
- Jimp.read(e.data).then(function (lenna) {
54
- lenna
55
- .resize(256, 256) // resize
56
- .quality(60) // set JPEG quality
57
- .greyscale() // set greyscale
58
- .getBase64(Jimp.MIME_JPEG, function (err, src) {
59
- self.postMessage(src); // message the main thread
60
- });
61
- });
62
- });
63
- ```
64
-
65
- ## License
66
-
67
- Jimp is licensed under the MIT license.
Binary file
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Jimp browser example 1</title>
5
- </head>
6
- <body>
7
- <h1>Demonstrates loading a local file using Jimp on the main thread</h1>
8
- <script src="../lib/jimp.js"></script>
9
- <script>
10
- Jimp.read(
11
- "https://upload.wikimedia.org/wikipedia/commons/0/01/Bot-Test.jpg"
12
- ).then(function (lenna) {
13
- lenna
14
- .resize(256, Jimp.AUTO) // resize
15
- .quality(60) // set JPEG quality
16
- .greyscale() // set greyscale
17
- .getBase64(Jimp.AUTO, function (err, src) {
18
- var img = document.createElement("img");
19
- img.setAttribute("src", src);
20
- document.body.appendChild(img);
21
- });
22
- });
23
- </script>
24
- </body>
25
- </html>
@@ -1,20 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Jimp browser example 2</title>
5
- </head>
6
- <body>
7
- <h1>
8
- Demonstrates loading a relative file using Jimp on a WebWorker thread
9
- </h1>
10
- <script>
11
- var worker = new Worker("jimp-worker.js");
12
- worker.onmessage = function (e) {
13
- var img = document.createElement("img");
14
- img.setAttribute("src", e.data);
15
- document.body.appendChild(img);
16
- };
17
- worker.postMessage("lenna.png");
18
- </script>
19
- </body>
20
- </html>
@@ -1,31 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Jimp browser example 3</title>
5
- </head>
6
- <body>
7
- <h1>Demonstrates loading a local file using Jimp on a WebWorker thread</h1>
8
- <p><input type="file" onchange="newFiles(this);" /></p>
9
- <script>
10
- function newFiles(element) {
11
- for (var i = 0; i < element.files.length; i++) {
12
- readFileAndProcess(element.files[i]);
13
- }
14
-
15
- function readFileAndProcess(readfile) {
16
- var reader = new FileReader();
17
- reader.addEventListener("load", function () {
18
- var worker = new Worker("jimp-worker.js");
19
- worker.onmessage = function (e) {
20
- var img = document.createElement("img");
21
- img.setAttribute("src", e.data);
22
- document.body.appendChild(img);
23
- };
24
- worker.postMessage(this.result);
25
- });
26
- reader.readAsArrayBuffer(readfile);
27
- }
28
- }
29
- </script>
30
- </body>
31
- </html>
@@ -1,74 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Jimp browser example 4</title>
5
- </head>
6
- <body>
7
- <h1>Demonstrates how to write a text over an image</h1>
8
- <script src="../lib/jimp.js"></script>
9
- <img id="pic" style="float: left; margin: 0px 20px 5px 0px" />
10
- <script>
11
- function writePic() {
12
- Jimp.read("lenna.png")
13
- .then(function (lenna) {
14
- var fntName = "FONT_SANS_" + fntSize.value + "_" + txtColor.value;
15
- var x = parseInt(txtX.value);
16
- var y = parseInt(txtY.value);
17
- var w = parseInt(txtW.value);
18
- console.log();
19
- Jimp.loadFont(Jimp[fntName])
20
- .then(function (font) {
21
- lenna
22
- .print(font, x, y, txtField.value, w)
23
- .getBase64(Jimp.AUTO, function (err, src) {
24
- if (err) {
25
- alert(err.message);
26
- throw err;
27
- }
28
- pic.setAttribute("src", src);
29
- });
30
- })
31
- .catch(function (err) {
32
- throw err;
33
- });
34
- })
35
- .catch(function (err) {
36
- alert("Image load fail.\n" + err.message);
37
- throw err;
38
- });
39
- return false;
40
- }
41
- writePic();
42
- </script>
43
- <textarea rows="4" cols="80" id="txtField">Hi! I'm Lenna.</textarea>
44
- <br />
45
- <label
46
- >Size:
47
- <select id="fntSize">
48
- <option>8</option>
49
- <option>16</option>
50
- <option>32</option>
51
- <option>64</option>
52
- <option>128</option>
53
- </select></label
54
- >
55
- <br />
56
- <label
57
- >Color:
58
- <select id="txtColor">
59
- <option>BLACK</option>
60
- <option>WHITE</option>
61
- </select></label
62
- >
63
- <br />
64
- <label>pos X: <input id="txtX" value="0" size="3" />px</label> <br />
65
- <label>pos Y: <input id="txtY" value="0" size="3" />px</label> <br />
66
- <label>max Width: <input id="txtW" value="400" size="3" />px</label> <br />
67
- <input
68
- type="button"
69
- id="btWrite"
70
- onclick="writePic(); return false"
71
- value="Write"
72
- />
73
- </body>
74
- </html>
@@ -1,18 +0,0 @@
1
- /* eslint-env worker */
2
- /* global Jimp */
3
-
4
- importScripts("../lib/jimp.js");
5
-
6
- self.addEventListener("message", (e) => {
7
- Jimp.read(e.data).then((lenna) => {
8
- lenna
9
- .resize(256, Jimp.AUTO) // resize
10
- .quality(60) // set JPEG quality
11
- .greyscale() // set greyscale
12
- .getBase64(Jimp.AUTO, (err, src) => {
13
- if (err) throw err;
14
- self.postMessage(src);
15
- self.close();
16
- });
17
- });
18
- });
Binary file
@@ -1,49 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Jimp browser example 1</title>
5
- </head>
6
- <body>
7
- <!-- Demonstrates loading a local file using Jimp on the main thread -->
8
- <script src="../lib/jimp.js"></script>
9
- <script>
10
- function dropShadow(x, y, b, a) {
11
- var img = new Jimp(
12
- this.bitmap.width + Math.abs(x * 2) + b * 2,
13
- this.bitmap.height + Math.abs(y * 2) + b * 2
14
- );
15
- var orig = this.clone();
16
- this.scan(
17
- 0,
18
- 0,
19
- this.bitmap.width,
20
- this.bitmap.height,
21
- function (x, y, idx) {
22
- this.bitmap.data[idx + 0] = 0;
23
- this.bitmap.data[idx + 1] = 0;
24
- this.bitmap.data[idx + 2] = 0;
25
- this.bitmap.data[idx + 3] = this.bitmap.data[idx + 3] * a;
26
- }
27
- );
28
- // this.resize(this.bitmap.width + Math.abs(x) + b, this.bitmap.height + Math.abs(y) + b);
29
-
30
- var x1 = Math.max(x * -1, 0) + b;
31
- var y1 = Math.max(y * -1, 0) + b;
32
- img.composite(this, x1, y1);
33
- img.blur(b);
34
- img.composite(orig, x1 - x, y1 - y);
35
- //img.autocrop();
36
- return img;
37
- }
38
- Jimp.read("dice.png").then(function (img) {
39
- console.log(img.getMIME(), img.getExtension());
40
- var img = dropShadow.call(img, 20, 20, 20, 0.3);
41
- img.getBase64(Jimp.AUTO, function (err, src) {
42
- var img = document.createElement("img");
43
- img.setAttribute("src", src);
44
- document.body.appendChild(img);
45
- });
46
- });
47
- </script>
48
- </body>
49
- </html>