jimp 0.16.3-canary.993.1592.0 → 0.16.3

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # v0.16.3 (Sat Feb 04 2023)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Fix edgeHandling types [#1080](https://github.com/jimp-dev/jimp/pull/1080) ([@domdomegg](https://github.com/domdomegg))
6
+ - Readme: Fix measureText sample code [#1102](https://github.com/jimp-dev/jimp/pull/1102) ([@dkong](https://github.com/dkong) [@hipstersmoothie](https://github.com/hipstersmoothie))
7
+
8
+ #### ⚠️ Pushed to `master`
9
+
10
+ - upgrade prettier ([@hipstersmoothie](https://github.com/hipstersmoothie))
11
+
12
+ #### Authors: 3
13
+
14
+ - Adam Jones ([@domdomegg](https://github.com/domdomegg))
15
+ - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
16
+ - Dara Kong ([@dkong](https://github.com/dkong))
17
+
18
+ ---
19
+
1
20
  # v0.15.0 (Fri Aug 07 2020)
2
21
 
3
22
  #### 🚀 Enhancement
@@ -102,7 +121,7 @@
102
121
 
103
122
  # v0.9.3 (Tue Nov 26 2019)
104
123
 
105
- #### 🐛 Bug Fix
124
+ #### 🐛 Bug Fix
106
125
 
107
126
  - `@jimp/cli`, `@jimp/core`, `@jimp/custom`, `jimp`, `@jimp/plugin-blit`, `@jimp/plugin-blur`, `@jimp/plugin-circle`, `@jimp/plugin-color`, `@jimp/plugin-contain`, `@jimp/plugin-cover`, `@jimp/plugin-crop`, `@jimp/plugin-displace`, `@jimp/plugin-dither`, `@jimp/plugin-fisheye`, `@jimp/plugin-flip`, `@jimp/plugin-gaussian`, `@jimp/plugin-invert`, `@jimp/plugin-mask`, `@jimp/plugin-normalize`, `@jimp/plugin-print`, `@jimp/plugin-resize`, `@jimp/plugin-rotate`, `@jimp/plugin-scale`, `@jimp/plugin-shadow`, `@jimp/plugin-threshold`, `@jimp/plugins`, `@jimp/test-utils`, `@jimp/bmp`, `@jimp/gif`, `@jimp/jpeg`, `@jimp/png`, `@jimp/tiff`, `@jimp/types`, `@jimp/utils`
108
127
  - Fix regeneratorRuntime errors [#815](https://github.com/oliver-moran/jimp/pull/815) ([@crutchcorn](https://github.com/crutchcorn) [@hipstersmoothie](https://github.com/hipstersmoothie))
@@ -110,4 +129,4 @@
110
129
  #### Authors: 2
111
130
 
112
131
  - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
113
- - Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))
132
+ - Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))
package/README.md CHANGED
@@ -26,31 +26,31 @@ Supported types:
26
26
  Example usage (Promise will never resolve if callback is passed):
27
27
 
28
28
  ```js
29
- var Jimp = require('jimp');
29
+ var Jimp = require("jimp");
30
30
 
31
31
  // open a file called "lenna.png"
32
- Jimp.read('lenna.png', (err, lenna) => {
32
+ Jimp.read("lenna.png", (err, lenna) => {
33
33
  if (err) throw err;
34
34
  lenna
35
35
  .resize(256, 256) // resize
36
36
  .quality(60) // set JPEG quality
37
37
  .greyscale() // set greyscale
38
- .write('lena-small-bw.jpg'); // save
38
+ .write("lena-small-bw.jpg"); // save
39
39
  });
40
40
  ```
41
41
 
42
42
  Using promises:
43
43
 
44
44
  ```js
45
- Jimp.read('lenna.png')
46
- .then(lenna => {
45
+ Jimp.read("lenna.png")
46
+ .then((lenna) => {
47
47
  return lenna
48
48
  .resize(256, 256) // resize
49
49
  .quality(60) // set JPEG quality
50
50
  .greyscale() // set greyscale
51
- .write('lena-small-bw.jpg'); // save
51
+ .write("lena-small-bw.jpg"); // save
52
52
  })
53
- .catch(err => {
53
+ .catch((err) => {
54
54
  console.error(err);
55
55
  });
56
56
  ```
@@ -60,7 +60,7 @@ Jimp.read('lenna.png')
60
60
  If you're using this library with TypeScript the method of importing slightly differs from JavaScript. Instead of using require, you must import it with ES6 default import scheme
61
61
 
62
62
  ```ts
63
- import Jimp from 'jimp';
63
+ import Jimp from "jimp";
64
64
  ```
65
65
 
66
66
  This requires setting the `allowSyntheticDefaultImports` compiler option to `true` in your `tsconfig`
@@ -74,7 +74,7 @@ This requires setting the `allowSyntheticDefaultImports` compiler option to `tru
74
74
  If you're using a web bundles (webpack, rollup, parcel) you can benefit from using the `module` build of jimp. Using the module build will allow your bundler to understand your code better and exclude things you aren't using.
75
75
 
76
76
  ```js
77
- import Jimp from 'jimp/es';
77
+ import Jimp from "jimp/es";
78
78
  ```
79
79
 
80
80
  ### WebPack
@@ -97,35 +97,35 @@ If you're using webpack you can set `process.browser` to true and your build of
97
97
  The static `Jimp.read` method takes the path to a file, URL, dimensions, a Jimp instance or a buffer and returns a Promise:
98
98
 
99
99
  ```js
100
- Jimp.read('./path/to/image.jpg')
101
- .then(image => {
100
+ Jimp.read("./path/to/image.jpg")
101
+ .then((image) => {
102
102
  // Do stuff with the image.
103
103
  })
104
- .catch(err => {
104
+ .catch((err) => {
105
105
  // Handle an exception.
106
106
  });
107
107
 
108
- Jimp.read('http://www.example.com/path/to/lenna.jpg')
109
- .then(image => {
108
+ Jimp.read("http://www.example.com/path/to/lenna.jpg")
109
+ .then((image) => {
110
110
  // Do stuff with the image.
111
111
  })
112
- .catch(err => {
112
+ .catch((err) => {
113
113
  // Handle an exception.
114
114
  });
115
115
 
116
116
  Jimp.read(jimpInstance)
117
- .then(image => {
117
+ .then((image) => {
118
118
  // Do stuff with the image.
119
119
  })
120
- .catch(err => {
120
+ .catch((err) => {
121
121
  // Handle an exception.
122
122
  });
123
123
 
124
124
  Jimp.read(buffer)
125
- .then(image => {
125
+ .then((image) => {
126
126
  // Do stuff with the image.
127
127
  })
128
- .catch(err => {
128
+ .catch((err) => {
129
129
  // Handle an exception.
130
130
  });
131
131
  ```
@@ -162,9 +162,9 @@ To define a custom constructor provide a name for it, a function to call to dete
162
162
 
163
163
  ```js
164
164
  Jimp.appendConstructorOption(
165
- 'Name of Option',
166
- args => arg.hasSomeCustomThing,
167
- function(resolve, reject, args) {
165
+ "Name of Option",
166
+ (args) => arg.hasSomeCustomThing,
167
+ function (resolve, reject, args) {
168
168
  this.bitmap = customParser(args);
169
169
  resolve();
170
170
  }
@@ -176,25 +176,25 @@ If you don't want to handle parsing the bitmap. For example if you want to do so
176
176
  Parse bitmap takes the raw image data in a Buffer, a path (optional), and a node style callback.
177
177
 
178
178
  ```js
179
- Jimp.appendConstructorOption('Custom Url', options => options.url, function(
180
- resolve,
181
- reject,
182
- options
183
- ) {
184
- phin(options, (err, res) => {
185
- if (err) {
186
- return reject(err);
187
- }
188
-
189
- this.parseBitmap(res.body, options.url, err => {
179
+ Jimp.appendConstructorOption(
180
+ "Custom Url",
181
+ (options) => options.url,
182
+ function (resolve, reject, options) {
183
+ phin(options, (err, res) => {
190
184
  if (err) {
191
185
  return reject(err);
192
186
  }
193
187
 
194
- resolve();
188
+ this.parseBitmap(res.body, options.url, (err) => {
189
+ if (err) {
190
+ return reject(err);
191
+ }
192
+
193
+ resolve();
194
+ });
195
195
  });
196
- });
197
- });
196
+ }
197
+ );
198
198
  ```
199
199
 
200
200
  ### Methods
@@ -358,7 +358,7 @@ Jimp.BLEND_EXCLUSION;
358
358
  image.composite(srcImage, 100, 0, {
359
359
  mode: Jimp.BLEND_MULTIPLY,
360
360
  opacitySource: 0.5,
361
- opacityDest: 0.9
361
+ opacityDest: 0.9,
362
362
  });
363
363
  ```
364
364
 
@@ -367,7 +367,7 @@ image.composite(srcImage, 100, 0, {
367
367
  Jimp supports basic typography using BMFont format (.fnt) even ones in different languages! Just find a bitmap font that is suitable [bitmap fonts](https://en.wikipedia.org/wiki/Bitmap_fonts):
368
368
 
369
369
  ```js
370
- Jimp.loadFont(pathOrURL).then(font => {
370
+ Jimp.loadFont(pathOrURL).then((font) => {
371
371
  // load font from .fnt file
372
372
  image.print(font, x, y, message); // print a message on an image. message can be a any type
373
373
  image.print(font, x, y, message, maxWidth); // print a message on an image with text wrapped at maxWidth
@@ -377,15 +377,15 @@ Jimp.loadFont(pathOrURL).then(font => {
377
377
  Alignment modes are supported by replacing the `str` argument with an object containing `text`, `alignmentX` and `alignmentY`. `alignmentX` defaults to `Jimp.HORIZONTAL_ALIGN_LEFT` and `alignmentY` defaults to `Jimp.VERTICAL_ALIGN_TOP`.
378
378
 
379
379
  ```js
380
- Jimp.loadFont(pathOrURL).then(font => {
380
+ Jimp.loadFont(pathOrURL).then((font) => {
381
381
  image.print(
382
382
  font,
383
383
  x,
384
384
  y,
385
385
  {
386
- text: 'Hello world!',
386
+ text: "Hello world!",
387
387
  alignmentX: Jimp.HORIZONTAL_ALIGN_CENTER,
388
- alignmentY: Jimp.VERTICAL_ALIGN_MIDDLE
388
+ alignmentY: Jimp.VERTICAL_ALIGN_MIDDLE,
389
389
  },
390
390
  maxWidth,
391
391
  maxHeight
@@ -419,8 +419,8 @@ Jimp.FONT_SANS_128_WHITE; // Open Sans, 128px, white
419
419
  These can be used as follows:
420
420
 
421
421
  ```js
422
- Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then(font => {
423
- image.print(font, 10, 10, 'Hello world!');
422
+ Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then((font) => {
423
+ image.print(font, 10, 10, "Hello world!");
424
424
  });
425
425
  ```
426
426
 
@@ -429,8 +429,12 @@ Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then(font => {
429
429
  If you need to do calculations on where to place your text jimp provides two methods that measure how wide and how tall a piece of text will be. You can use these methods to lay out multiple pieces of text in relation to each other
430
430
 
431
431
  ```js
432
- Jimp.measureText((await Jimp.loadFont(Jimp.FONT_SANS_32_BLACK)), 'Some string'); // width of text
433
- Jimp.measureTextHeight((await Jimp.loadFont(Jimp.FONT_SANS_32_BLACK)), 'Some string', 100); // height of text
432
+ Jimp.measureText(await Jimp.loadFont(Jimp.FONT_SANS_32_BLACK), "Some string"); // width of text
433
+ Jimp.measureTextHeight(
434
+ await Jimp.loadFont(Jimp.FONT_SANS_32_BLACK),
435
+ "Some string",
436
+ 100
437
+ ); // height of text
434
438
  ```
435
439
 
436
440
  #### Staggering Text
@@ -438,15 +442,15 @@ Jimp.measureTextHeight((await Jimp.loadFont(Jimp.FONT_SANS_32_BLACK)), 'Some str
438
442
  If you need to stagger text position along the x or y-axis the print method also returns the final coordinates as an argument to the callback.
439
443
 
440
444
  ```js
441
- Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then(font => {
445
+ Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then((font) => {
442
446
  image.print(
443
447
  font,
444
448
  10,
445
449
  10,
446
- 'Hello world that wraps!',
450
+ "Hello world that wraps!",
447
451
  50,
448
452
  (err, image, { x, y }) => {
449
- image.print(font, x, y + 20, 'More text on another line', 50);
453
+ image.print(font, x, y + 20, "More text on another line", 50);
450
454
  }
451
455
  );
452
456
  });
@@ -472,9 +476,9 @@ image.writeAsync(path); // Returns Promise
472
476
  The original extension for an image (or "png") can accessed as using `image.getExtension()`. The following will save an image using its original format:
473
477
 
474
478
  ```js
475
- var file = 'new_name.' + image.getExtension();
479
+ var file = "new_name." + image.getExtension();
476
480
  //or
477
- var file = 'new_name'; // with no extension
481
+ var file = "new_name"; // with no extension
478
482
  image.write(file);
479
483
  ```
480
484
 
@@ -542,9 +546,9 @@ Jimp supports advanced colour manipulation using a single method as follows:
542
546
 
543
547
  ```js
544
548
  image.color([
545
- { apply: 'hue', params: [-90] },
546
- { apply: 'lighten', params: [50] },
547
- { apply: 'xor', params: ['#06D'] }
549
+ { apply: "hue", params: [-90] },
550
+ { apply: "lighten", params: [50] },
551
+ { apply: "xor", params: ["#06D"] },
548
552
  ]);
549
553
  ```
550
554
 
@@ -575,7 +579,11 @@ Sum neighbor pixels weighted by the kernel matrix. You can find a nice explanati
575
579
  Implement emboss effect:
576
580
 
577
581
  ```js
578
- image.convolute([[-2, -1, 0], [-1, 1, 1], [0, 1, 2]]);
582
+ image.convolute([
583
+ [-2, -1, 0],
584
+ [-1, 1, 1],
585
+ [0, 1, 2],
586
+ ]);
579
587
  ```
580
588
 
581
589
  ### Low-level manipulation
@@ -599,7 +607,7 @@ image.scan(x, y, w, h, f); // scan a given region of the bitmap and call the fun
599
607
  Example usage:
600
608
 
601
609
  ```js
602
- image.scan(0, 0, image.bitmap.width, image.bitmap.height, function(x, y, idx) {
610
+ image.scan(0, 0, image.bitmap.width, image.bitmap.height, function (x, y, idx) {
603
611
  // x, y is the position of this pixel on the image
604
612
  // idx is the position start position of this rgba tuple in the bitmap Buffer
605
613
  // this is the image
@@ -617,7 +625,7 @@ image.scan(0, 0, image.bitmap.width, image.bitmap.height, function(x, y, idx) {
617
625
  If you need to do something with the image at the end of the scan:
618
626
 
619
627
  ```js
620
- image.scan(0, 0, image.bitmap.width, image.bitmap.height, function(x, y, idx) {
628
+ image.scan(0, 0, image.bitmap.width, image.bitmap.height, function (x, y, idx) {
621
629
  // do your stuff..
622
630
 
623
631
  if (x == image.bitmap.width - 1 && y == image.bitmap.height - 1) {
@@ -693,7 +701,7 @@ new Jimp(256, 256, 0xff0000ff, (err, image) => {
693
701
  Or you can use a css color format:
694
702
 
695
703
  ```js
696
- new Jimp(256, 256, '#FF00FF', (err, image) => {
704
+ new Jimp(256, 256, "#FF00FF", (err, image) => {
697
705
  // this image is 256 x 256, every pixel is set to #FF00FF
698
706
  });
699
707
  ```
@@ -766,21 +774,18 @@ Jimp.compareHashes(hash1, hash2); // same result as above
766
774
  Most instance methods can be chained together, for example as follows:
767
775
 
768
776
  ```js
769
- Jimp.read('lenna.png').then(image => {
770
- image
771
- .greyscale()
772
- .scale(0.5)
773
- .write('lena-half-bw.png');
777
+ Jimp.read("lenna.png").then((image) => {
778
+ image.greyscale().scale(0.5).write("lena-half-bw.png");
774
779
  });
775
780
  ```
776
781
 
777
782
  Alternatively, methods can be passed Node-style callbacks:
778
783
 
779
784
  ```js
780
- Jimp.read('lenna.png').then(image => {
785
+ Jimp.read("lenna.png").then((image) => {
781
786
  image.greyscale((err, image) => {
782
787
  image.scale(0.5, (err, image) => {
783
- image.write('lena-half-bw.png');
788
+ image.write("lena-half-bw.png");
784
789
  });
785
790
  });
786
791
  });
package/browser/README.md CHANGED
@@ -7,18 +7,21 @@ Example usage:
7
7
  ```html
8
8
  <script src="jimp.min.js"></script>
9
9
  <script>
10
- Jimp.read("lenna.png").then(function (lenna) {
11
- lenna.resize(256, 256) // resize
12
- .quality(60) // set JPEG quality
13
- .greyscale() // set greyscale
14
- .getBase64(Jimp.MIME_JPEG, function (err, src) {
15
- var img = document.createElement("img");
16
- img.setAttribute("src", src);
17
- document.body.appendChild(img);
18
- });
19
- }).catch(function (err) {
20
- console.error(err);
21
- });
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
+ });
22
25
  </script>
23
26
  ```
24
27
 
@@ -31,28 +34,28 @@ For better performance, it recommended that Jimp methods are run on a separate t
31
34
  ```js
32
35
  // index.html
33
36
 
34
- var worker = new Worker('jimp-worker.js');
35
- worker.onmessage = function(e) {
37
+ var worker = new Worker("jimp-worker.js");
38
+ worker.onmessage = function (e) {
36
39
  // append a new img element using the base 64 image
37
- var img = document.createElement('img');
38
- img.setAttribute('src', e.data);
40
+ var img = document.createElement("img");
41
+ img.setAttribute("src", e.data);
39
42
  document.body.appendChild(img);
40
43
  };
41
- worker.postMessage('lenna.png'); // message the worker thread
44
+ worker.postMessage("lenna.png"); // message the worker thread
42
45
  ```
43
46
 
44
47
  ```js
45
48
  // jimp-worker.js
46
49
 
47
- importScripts('jimp.min.js');
50
+ importScripts("jimp.min.js");
48
51
 
49
- self.addEventListener('message', function(e) {
50
- Jimp.read(e.data).then(function(lenna) {
52
+ self.addEventListener("message", function (e) {
53
+ Jimp.read(e.data).then(function (lenna) {
51
54
  lenna
52
55
  .resize(256, 256) // resize
53
56
  .quality(60) // set JPEG quality
54
57
  .greyscale() // set greyscale
55
- .getBase64(Jimp.MIME_JPEG, function(err, src) {
58
+ .getBase64(Jimp.MIME_JPEG, function (err, src) {
56
59
  self.postMessage(src); // message the main thread
57
60
  });
58
61
  });
@@ -1,24 +1,25 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Jimp browser example 1</title>
5
- </head>
6
- <body>
7
-
8
- <h1> Demonstrates loading a local file using Jimp on the main thread </h1>
9
- <script src="../lib/jimp.min.js"></script>
10
- <script>
11
- Jimp.read("https://upload.wikimedia.org/wikipedia/commons/0/01/Bot-Test.jpg").then(function (lenna) {
12
- lenna.resize(256, Jimp.AUTO) // resize
13
- .quality(60) // set JPEG quality
14
- .greyscale() // set greyscale
15
- .getBase64(Jimp.AUTO, function (err, src) {
16
- var img = document.createElement("img");
17
- img.setAttribute("src", src);
18
- document.body.appendChild(img);
19
- });
20
- });
21
- </script>
22
-
23
- </body>
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.min.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>
24
25
  </html>
@@ -1,20 +1,20 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Jimp browser example 2</title>
5
- </head>
6
- <body>
7
-
8
- <h1> Demonstrates loading a relative file using Jimp on a WebWorker thread </h1>
9
- <script>
10
- var worker = new Worker("jimp-worker.js");
11
- worker.onmessage = function (e) {
12
- var img = document.createElement("img");
13
- img.setAttribute("src", e.data);
14
- document.body.appendChild(img);
15
- };
16
- worker.postMessage("lenna.png");
17
- </script>
18
-
19
- </body>
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
20
  </html>
@@ -1,35 +1,31 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Jimp browser example 3</title>
5
- </head>
6
- <body>
7
-
8
- <h1> Demonstrates loading a local file using Jimp on a WebWorker thread </h1>
9
- <p><input type="file" onchange="newFiles(this);" /></p>
10
- <script>
11
-
12
- function newFiles(element){
13
- for (var i=0; i<element.files.length; i++) {
14
- readFileAndProcess(element.files[i]);
15
- }
16
-
17
- function readFileAndProcess(readfile){
18
- var reader = new FileReader();
19
- reader.addEventListener("load", function(){
20
- var worker = new Worker("jimp-worker.js");
21
- worker.onmessage = function (e) {
22
- var img = document.createElement("img");
23
- img.setAttribute("src", e.data);
24
- document.body.appendChild(img);
25
- };
26
- worker.postMessage(this.result);
27
- });
28
- reader.readAsArrayBuffer(readfile);
29
- }
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]);
30
13
  }
31
14
 
32
- </script>
33
-
34
- </body>
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>
35
31
  </html>