imagescript 1.3.0 → 3.0.0

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 (146) hide show
  1. package/LICENSE +4 -1
  2. package/README.md +64 -26
  3. package/THIRD_PARTY_NOTICES.md +74 -0
  4. package/dist/codecs/crc.d.ts +9 -0
  5. package/dist/codecs/crc.js +29 -0
  6. package/dist/codecs/exif.d.ts +11 -0
  7. package/dist/codecs/exif.js +27 -0
  8. package/dist/codecs/gif.d.ts +44 -0
  9. package/dist/codecs/gif.js +401 -0
  10. package/dist/codecs/jpeg.d.ts +35 -0
  11. package/dist/codecs/jpeg.js +980 -0
  12. package/dist/codecs/png.d.ts +44 -0
  13. package/dist/codecs/png.js +442 -0
  14. package/dist/codecs/quantize.d.ts +25 -0
  15. package/dist/codecs/quantize.js +302 -0
  16. package/dist/codecs/tiff.d.ts +6 -0
  17. package/dist/codecs/tiff.js +546 -0
  18. package/dist/codecs/zlib.d.ts +22 -0
  19. package/dist/codecs/zlib.js +607 -0
  20. package/dist/frame.d.ts +57 -0
  21. package/dist/frame.js +65 -0
  22. package/dist/gif.d.ts +44 -0
  23. package/dist/gif.js +93 -0
  24. package/dist/image-type.d.ts +20 -0
  25. package/dist/image-type.js +49 -0
  26. package/dist/image.d.ts +521 -0
  27. package/dist/image.js +1118 -0
  28. package/dist/index.d.ts +19 -0
  29. package/dist/index.js +13 -0
  30. package/dist/package.json +1 -0
  31. package/dist/render/font.d.ts +63 -0
  32. package/dist/render/font.js +857 -0
  33. package/dist/render/svg.d.ts +11 -0
  34. package/dist/render/svg.js +1717 -0
  35. package/dist/render/text.d.ts +61 -0
  36. package/dist/render/text.js +317 -0
  37. package/dist/text-layout.d.ts +46 -0
  38. package/dist/text-layout.js +35 -0
  39. package/dist/util/blur.d.ts +13 -0
  40. package/dist/util/blur.js +146 -0
  41. package/dist/util/mem.d.ts +10 -0
  42. package/dist/util/mem.js +23 -0
  43. package/dist/util/resample.d.ts +12 -0
  44. package/dist/util/resample.js +99 -0
  45. package/dist/util/utf8.d.ts +5 -0
  46. package/dist/util/utf8.js +55 -0
  47. package/dist/version.d.ts +1 -0
  48. package/dist/version.js +1 -0
  49. package/licenses/Apache-2.0.txt +202 -0
  50. package/licenses/README.ijg +260 -0
  51. package/package.json +31 -7
  52. package/ImageScript.d.ts +0 -235
  53. package/ImageScript.js +0 -1669
  54. package/bench/_.mjs +0 -166
  55. package/bench/all.mjs +0 -4
  56. package/bench/blur.mjs +0 -59
  57. package/bench/flip.mjs +0 -63
  58. package/bench/overlay.mjs +0 -35
  59. package/bench/package.json +0 -7
  60. package/bench/readme.md +0 -64
  61. package/bench/resize.mjs +0 -52
  62. package/codecs/LICENSE +0 -21
  63. package/codecs/lib.d.ts +0 -50
  64. package/codecs/lib.js +0 -6
  65. package/codecs/lib.mjs +0 -1
  66. package/codecs/node/bin/arm64-darwin.node +0 -0
  67. package/codecs/node/bin/arm64-linux.node +0 -0
  68. package/codecs/node/bin/x64-darwin.node +0 -0
  69. package/codecs/node/bin/x64-linux.node +0 -0
  70. package/codecs/node/bin/x64-win32.node +0 -0
  71. package/codecs/node/index.js +0 -3
  72. package/codecs/node/index.mjs +0 -6
  73. package/codecs/package.json +0 -14
  74. package/codecs/readme.md +0 -38
  75. package/codecs/tests/gif.js +0 -0
  76. package/codecs/tests/jpeg.js +0 -0
  77. package/codecs/tests/png.js +0 -0
  78. package/codecs/tests/results/gif/1024.nis.gif +0 -0
  79. package/codecs/tests/results/gif/1024.skyra.gif +0 -0
  80. package/codecs/tests/results/gif/256.nis.gif +0 -0
  81. package/codecs/tests/results/gif/256.skyra.gif +0 -0
  82. package/codecs/tests/results/jpeg/256.jpegjs.jpeg +0 -0
  83. package/codecs/tests/results/jpeg/256.nis.jpeg +0 -0
  84. package/codecs/tests/results/jpeg/256.sharp.jpeg +0 -0
  85. package/codecs/tests/results/jpeg/512.jpegjs.jpeg +0 -0
  86. package/codecs/tests/results/jpeg/512.nis.jpeg +0 -0
  87. package/codecs/tests/results/jpeg/512.sharp.jpeg +0 -0
  88. package/codecs/tests/results/jpeg/64.jpegjs.jpeg +0 -0
  89. package/codecs/tests/results/jpeg/64.nis.jpeg +0 -0
  90. package/codecs/tests/results/jpeg/64.sharp.jpeg +0 -0
  91. package/codecs/tests/results/png/256.jis.png +0 -0
  92. package/codecs/tests/results/png/256.nis.png +0 -0
  93. package/codecs/tests/results/png/256.sharp.png +0 -0
  94. package/codecs/tests/results/png/256.upng.png +0 -0
  95. package/codecs/tests/results/png/512.jis.png +0 -0
  96. package/codecs/tests/results/png/512.nis.png +0 -0
  97. package/codecs/tests/results/png/512.sharp.png +0 -0
  98. package/codecs/tests/results/png/512.upng.png +0 -0
  99. package/codecs/tests/results/png/64.jis.png +0 -0
  100. package/codecs/tests/results/png/64.nis.png +0 -0
  101. package/codecs/tests/results/png/64.sharp.png +0 -0
  102. package/codecs/tests/results/png/64.upng.png +0 -0
  103. package/codecs/tests/webp.js +0 -0
  104. package/codecs/wasm/bin/codecs.wasm +0 -0
  105. package/codecs/wasm/bin/simd.wasm +0 -0
  106. package/codecs/wasm/bundle/browser.js +0 -1
  107. package/codecs/wasm/index.js +0 -1
  108. package/codecs/wasm/index.mjs +0 -1
  109. package/png/README.md +0 -1
  110. package/png/node.js +0 -1137
  111. package/png/src/crc.mjs +0 -49
  112. package/png/src/mem.mjs +0 -24
  113. package/png/src/png.mjs +0 -254
  114. package/png/src/zlib.mjs +0 -618
  115. package/tsconfig.json +0 -21
  116. package/utils/mem.js +0 -26
  117. package/v2/codecs/magic.js +0 -25
  118. package/v2/framebuffer.d.ts +0 -67
  119. package/v2/framebuffer.js +0 -2352
  120. package/v2/framebuffer.mjs +0 -126
  121. package/v2/framebuffer.rs +0 -1264
  122. package/v2/index.d.ts +0 -84
  123. package/v2/index.js +0 -261
  124. package/v2/ops/blur.mjs +0 -303
  125. package/v2/ops/color.mjs +0 -277
  126. package/v2/ops/crop.mjs +0 -64
  127. package/v2/ops/fill.mjs +0 -33
  128. package/v2/ops/flip.mjs +0 -33
  129. package/v2/ops/index.mjs +0 -9
  130. package/v2/ops/iterator.mjs +0 -34
  131. package/v2/ops/overlay.mjs +0 -63
  132. package/v2/ops/resize.mjs +0 -166
  133. package/v2/ops/rotate.mjs +0 -117
  134. package/v2/util/mem.mjs +0 -24
  135. package/wasm/any/font.wasm +0 -0
  136. package/wasm/any/gif.wasm +0 -0
  137. package/wasm/any/jpeg.wasm +0 -0
  138. package/wasm/any/png.wasm +0 -0
  139. package/wasm/any/svg.wasm +0 -0
  140. package/wasm/any/tiff.wasm +0 -0
  141. package/wasm/node/font.js +0 -142
  142. package/wasm/node/gif.js +0 -76
  143. package/wasm/node/jpeg.js +0 -92
  144. package/wasm/node/png.js +0 -49
  145. package/wasm/node/svg.js +0 -56
  146. package/wasm/node/tiff.js +0 -47
@@ -0,0 +1,99 @@
1
+ export const BOX = { support: 0.5, weight: x => x >= -0.5 && x < 0.5 ? 1 : 0 };
2
+ export const TRIANGLE = { support: 1, weight: x => Math.max(0, 1 - Math.abs(x)) };
3
+ export const CUBIC = {
4
+ support: 2,
5
+ weight: x => {
6
+ const a = -0.5;
7
+ x = Math.abs(x);
8
+ if (x < 1)
9
+ return ((a + 2) * x - (a + 3)) * x * x + 1;
10
+ if (x < 2)
11
+ return (((x - 5) * x + 8) * x - 4) * a;
12
+ return 0;
13
+ }
14
+ };
15
+ function coefficients(inSize, outSize, filter) {
16
+ const scale = inSize / outSize;
17
+ const filterScale = Math.max(1, scale);
18
+ const support = filter.support * filterScale;
19
+ const size = Math.ceil(support) * 2 + 1;
20
+ const start = new Int32Array(outSize);
21
+ const count = new Int32Array(outSize);
22
+ const weights = new Float64Array(outSize * size);
23
+ for (let i = 0; i < outSize; i++) {
24
+ const center = (i + 0.5) * scale;
25
+ const min = Math.max(0, Math.floor(center - support + 0.5));
26
+ const max = Math.min(inSize, Math.floor(center + support + 0.5));
27
+ let total = 0;
28
+ for (let x = min; x < max; x++) {
29
+ const w = filter.weight((x - center + 0.5) / filterScale);
30
+ weights[i * size + x - min] = w;
31
+ total += w;
32
+ }
33
+ if (total !== 0)
34
+ for (let k = 0; k < max - min; k++)
35
+ weights[i * size + k] /= total;
36
+ start[i] = min;
37
+ count[i] = max - min;
38
+ }
39
+ return { start, count, weights, size };
40
+ }
41
+ export function resample(src, width, height, outWidth, outHeight, filter, out) {
42
+ let plane = new Float32Array(outWidth * height * 4);
43
+ const horizontal = outWidth !== width ? coefficients(width, outWidth, filter) : null;
44
+ for (let y = 0; y < height; y++) {
45
+ const row = y * width * 4;
46
+ for (let x = 0; x < outWidth; x++) {
47
+ let r = 0, g = 0, b = 0, a = 0;
48
+ if (horizontal) {
49
+ const { start, count, weights, size } = horizontal;
50
+ for (let k = 0, s = row + start[x] * 4; k < count[x]; k++, s += 4) {
51
+ const wa = weights[x * size + k] * src[s + 3];
52
+ r += src[s] * wa;
53
+ g += src[s + 1] * wa;
54
+ b += src[s + 2] * wa;
55
+ a += wa;
56
+ }
57
+ }
58
+ else {
59
+ const s = row + x * 4;
60
+ a = src[s + 3];
61
+ r = src[s] * a;
62
+ g = src[s + 1] * a;
63
+ b = src[s + 2] * a;
64
+ }
65
+ const o = (y * outWidth + x) * 4;
66
+ plane[o] = r / 255;
67
+ plane[o + 1] = g / 255;
68
+ plane[o + 2] = b / 255;
69
+ plane[o + 3] = a;
70
+ }
71
+ }
72
+ if (outHeight !== height) {
73
+ const { start, count, weights, size } = coefficients(height, outHeight, filter);
74
+ const next = new Float32Array(outWidth * outHeight * 4);
75
+ const stride = outWidth * 4;
76
+ for (let y = 0; y < outHeight; y++) {
77
+ const o = y * stride;
78
+ for (let k = 0; k < count[y]; k++) {
79
+ const w = weights[y * size + k];
80
+ const s = (start[y] + k) * stride;
81
+ for (let x = 0; x < stride; x++)
82
+ next[o + x] += plane[s + x] * w;
83
+ }
84
+ }
85
+ plane = next;
86
+ }
87
+ for (let i = 0; i < plane.length; i += 4) {
88
+ const a = plane[i + 3];
89
+ if (a < 0.5) {
90
+ out[i] = out[i + 1] = out[i + 2] = out[i + 3] = 0;
91
+ continue;
92
+ }
93
+ const f = 255 / Math.min(255, a);
94
+ out[i] = plane[i] * f;
95
+ out[i + 1] = plane[i + 1] * f;
96
+ out[i + 2] = plane[i + 2] * f;
97
+ out[i + 3] = a;
98
+ }
99
+ }
@@ -0,0 +1,5 @@
1
+ export declare function encode(text: string): Uint8Array;
2
+ /**
3
+ * Decodes UTF-8, replacing invalid sequences with U+FFFD and skipping a leading byte order mark
4
+ */
5
+ export declare function decode(bytes: Uint8Array): string;
@@ -0,0 +1,55 @@
1
+ export function encode(text) {
2
+ const out = [];
3
+ for (const char of text) {
4
+ const c = char.codePointAt(0);
5
+ if (c < 0x80)
6
+ out.push(c);
7
+ else if (c < 0x800)
8
+ out.push(0xc0 | c >> 6, 0x80 | c & 63);
9
+ else if (c < 0x10000)
10
+ out.push(0xe0 | c >> 12, 0x80 | c >> 6 & 63, 0x80 | c & 63);
11
+ else
12
+ out.push(0xf0 | c >> 18, 0x80 | c >> 12 & 63, 0x80 | c >> 6 & 63, 0x80 | c & 63);
13
+ }
14
+ return Uint8Array.from(out);
15
+ }
16
+ export function decode(bytes) {
17
+ let out = '';
18
+ let i = bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf ? 3 : 0;
19
+ while (i < bytes.length) {
20
+ const b = bytes[i++];
21
+ let c, extra;
22
+ if (b < 0x80) {
23
+ c = b;
24
+ extra = 0;
25
+ }
26
+ else if (b >= 0xc2 && b < 0xe0) {
27
+ c = b & 31;
28
+ extra = 1;
29
+ }
30
+ else if (b >= 0xe0 && b < 0xf0) {
31
+ c = b & 15;
32
+ extra = 2;
33
+ }
34
+ else if (b >= 0xf0 && b < 0xf5) {
35
+ c = b & 7;
36
+ extra = 3;
37
+ }
38
+ else {
39
+ out += '�';
40
+ continue;
41
+ }
42
+ let valid = true;
43
+ for (let k = 0; k < extra; k++) {
44
+ const next = bytes[i];
45
+ if (next === undefined || (next & 0xc0) !== 0x80) {
46
+ valid = false;
47
+ break;
48
+ }
49
+ c = c << 6 | next & 63;
50
+ i++;
51
+ }
52
+ out += valid && c <= 0x10ffff ? String.fromCodePoint(c) : '�';
53
+ }
54
+ return out;
55
+ }
@@ -0,0 +1 @@
1
+ export declare const VERSION = "3.0.0";
@@ -0,0 +1 @@
1
+ export const VERSION = '3.0.0';
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,260 @@
1
+ libjpeg-turbo note: This file has been modified by The libjpeg-turbo Project
2
+ to include only information relevant to libjpeg-turbo, to wordsmith certain
3
+ sections, and to remove impolitic language that existed in the libjpeg v8
4
+ README. It is included only for reference. Please see README.md for
5
+ information specific to libjpeg-turbo.
6
+
7
+
8
+ The Independent JPEG Group's JPEG software
9
+ ==========================================
10
+
11
+ This distribution contains a release of the Independent JPEG Group's free JPEG
12
+ software. You are welcome to redistribute this software and to use it for any
13
+ purpose, subject to the conditions under LEGAL ISSUES, below.
14
+
15
+ This software is the work of Tom Lane, Guido Vollbeding, Philip Gladstone,
16
+ Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson,
17
+ Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Ge' Weijers,
18
+ and other members of the Independent JPEG Group.
19
+
20
+ IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee
21
+ (also known as JPEG, together with ITU-T SG16).
22
+
23
+
24
+ DOCUMENTATION ROADMAP
25
+ =====================
26
+
27
+ This file contains the following sections:
28
+
29
+ OVERVIEW General description of JPEG and the IJG software.
30
+ LEGAL ISSUES Copyright, lack of warranty, terms of distribution.
31
+ REFERENCES Where to learn more about JPEG.
32
+ ARCHIVE LOCATIONS Where to find newer versions of this software.
33
+ FILE FORMAT WARS Software *not* to get.
34
+ TO DO Plans for future IJG releases.
35
+
36
+ Other documentation files in the distribution are:
37
+
38
+ User documentation:
39
+ doc/usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
40
+ rdjpgcom, and wrjpgcom.
41
+ doc/*.1 Unix-style man pages for programs (same info as
42
+ usage.txt).
43
+ doc/wizard.txt Advanced usage instructions for JPEG wizards only.
44
+ doc/change.log Version-to-version change highlights.
45
+ Programmer and internal documentation:
46
+ doc/libjpeg.txt How to use the JPEG library in your own programs.
47
+ src/example.c Sample code for calling the JPEG library.
48
+ doc/structure.txt Overview of the JPEG library's internal structure.
49
+ doc/coderules.txt Coding style rules --- please read if you contribute
50
+ code.
51
+
52
+ Please read at least usage.txt. Some information can also be found in the JPEG
53
+ FAQ (Frequently Asked Questions) article. See ARCHIVE LOCATIONS below to find
54
+ out where to obtain the FAQ article.
55
+
56
+ If you want to understand how the JPEG code works, we suggest reading one or
57
+ more of the REFERENCES, then looking at the documentation files (in roughly
58
+ the order listed) before diving into the code.
59
+
60
+
61
+ OVERVIEW
62
+ ========
63
+
64
+ This package contains C software to implement JPEG image encoding, decoding,
65
+ and transcoding. JPEG (pronounced "jay-peg") is a standardized compression
66
+ method for full-color and grayscale images. JPEG's strong suit is compressing
67
+ photographic images or other types of images that have smooth color and
68
+ brightness transitions between neighboring pixels. Images with sharp lines or
69
+ other abrupt features may not compress well with JPEG, and a higher JPEG
70
+ quality may have to be used to avoid visible compression artifacts with such
71
+ images.
72
+
73
+ JPEG is normally lossy, meaning that the output pixels are not necessarily
74
+ identical to the input pixels. However, on photographic content and other
75
+ "smooth" images, very good compression ratios can be obtained with no visible
76
+ compression artifacts, and extremely high compression ratios are possible if
77
+ you are willing to sacrifice image quality (by reducing the "quality" setting
78
+ in the compressor.)
79
+
80
+ This software implements JPEG baseline, extended-sequential, progressive, and
81
+ lossless compression processes. Provision is made for supporting all variants
82
+ of these processes, although some uncommon parameter settings aren't
83
+ implemented yet. We have made no provision for supporting the hierarchical
84
+ processes defined in the standard.
85
+
86
+ We provide a set of library routines for reading and writing JPEG image files,
87
+ plus two sample applications "cjpeg" and "djpeg", which use the library to
88
+ perform conversion between JPEG and some other popular image file formats.
89
+ The library is intended to be reused in other applications.
90
+
91
+ In order to support file conversion and viewing software, we have included
92
+ considerable functionality beyond the bare JPEG coding/decoding capability;
93
+ for example, the color quantization modules are not strictly part of JPEG
94
+ decoding, but they are essential for output to colormapped file formats. These
95
+ extra functions can be compiled out of the library if not required for a
96
+ particular application.
97
+
98
+ We have also included "jpegtran", a utility for lossless transcoding between
99
+ different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple
100
+ applications for inserting and extracting textual comments in JFIF files.
101
+
102
+ The emphasis in designing this software has been on achieving portability and
103
+ flexibility, while also making it fast enough to be useful. In particular,
104
+ the software is not intended to be read as a tutorial on JPEG. (See the
105
+ REFERENCES section for introductory material.) Rather, it is intended to
106
+ be reliable, portable, industrial-strength code. We do not claim to have
107
+ achieved that goal in every aspect of the software, but we strive for it.
108
+
109
+ We welcome the use of this software as a component of commercial products.
110
+ No royalty is required, but we do ask for an acknowledgement in product
111
+ documentation, as described under LEGAL ISSUES.
112
+
113
+
114
+ LEGAL ISSUES
115
+ ============
116
+
117
+ In plain English:
118
+
119
+ 1. We don't promise that this software works. (But if you find any bugs,
120
+ please let us know!)
121
+ 2. You can use this software for whatever you want. You don't have to pay us.
122
+ 3. You may not pretend that you wrote this software. If you use it in a
123
+ program, you must acknowledge somewhere in your documentation that
124
+ you've used the IJG code.
125
+
126
+ In legalese:
127
+
128
+ The authors make NO WARRANTY or representation, either express or implied,
129
+ with respect to this software, its quality, accuracy, merchantability, or
130
+ fitness for a particular purpose. This software is provided "AS IS", and you,
131
+ its user, assume the entire risk as to its quality and accuracy.
132
+
133
+ This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
134
+ All Rights Reserved except as specified below.
135
+
136
+ Permission is hereby granted to use, copy, modify, and distribute this
137
+ software (or portions thereof) for any purpose, without fee, subject to these
138
+ conditions:
139
+ (1) If any part of the source code for this software is distributed, then this
140
+ README file must be included, with this copyright and no-warranty notice
141
+ unaltered; and any additions, deletions, or changes to the original files
142
+ must be clearly indicated in accompanying documentation.
143
+ (2) If only executable code is distributed, then the accompanying
144
+ documentation must state that "this software is based in part on the work of
145
+ the Independent JPEG Group".
146
+ (3) Permission for use of this software is granted only if the user accepts
147
+ full responsibility for any undesirable consequences; the authors accept
148
+ NO LIABILITY for damages of any kind.
149
+
150
+ These conditions apply to any software derived from or based on the IJG code,
151
+ not just to the unmodified library. If you use our work, you ought to
152
+ acknowledge us.
153
+
154
+ Permission is NOT granted for the use of any IJG author's name or company name
155
+ in advertising or publicity relating to this software or products derived from
156
+ it. This software may be referred to only as "the Independent JPEG Group's
157
+ software".
158
+
159
+ We specifically permit and encourage the use of this software as the basis of
160
+ commercial products, provided that all warranty or liability claims are
161
+ assumed by the product vendor.
162
+
163
+
164
+ REFERENCES
165
+ ==========
166
+
167
+ We recommend reading one or more of these references before trying to
168
+ understand the innards of the JPEG software.
169
+
170
+ The best short technical introduction to the JPEG compression algorithm is
171
+ Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
172
+ Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.
173
+ (Adjacent articles in that issue discuss MPEG motion picture compression,
174
+ applications of JPEG, and related topics.) If you don't have the CACM issue
175
+ handy, a PDF file containing a revised version of Wallace's article is
176
+ available at http://www.ijg.org/files/Wallace.JPEG.pdf. The file (actually
177
+ a preprint for an article that appeared in IEEE Trans. Consumer Electronics)
178
+ omits the sample images that appeared in CACM, but it includes corrections
179
+ and some added material. Note: the Wallace article is copyright ACM and IEEE,
180
+ and it may not be used for commercial purposes.
181
+
182
+ A somewhat less technical, more leisurely introduction to JPEG can be found in
183
+ "The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by
184
+ M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides
185
+ good explanations and example C code for a multitude of compression methods
186
+ including JPEG. It is an excellent source if you are comfortable reading C
187
+ code but don't know much about data compression in general. The book's JPEG
188
+ sample code is far from industrial-strength, but when you are ready to look
189
+ at a full implementation, you've got one here...
190
+
191
+ The best currently available description of JPEG is the textbook "JPEG Still
192
+ Image Data Compression Standard" by William B. Pennebaker and Joan L.
193
+ Mitchell, published by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1.
194
+ Price US$59.95, 638 pp. The book includes the complete text of the ISO JPEG
195
+ standards (DIS 10918-1 and draft DIS 10918-2).
196
+
197
+ The original JPEG standard is divided into two parts, Part 1 being the actual
198
+ specification, while Part 2 covers compliance testing methods. Part 1 is
199
+ titled "Digital Compression and Coding of Continuous-tone Still Images,
200
+ Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS
201
+ 10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of
202
+ Continuous-tone Still Images, Part 2: Compliance testing" and has document
203
+ numbers ISO/IEC IS 10918-2, ITU-T T.83.
204
+
205
+ The JPEG standard does not specify all details of an interchangeable file
206
+ format. For the omitted details, we follow the "JFIF" conventions, revision
207
+ 1.02. JFIF version 1 has been adopted as ISO/IEC 10918-5 (05/2013) and
208
+ Recommendation ITU-T T.871 (05/2011): Information technology - Digital
209
+ compression and coding of continuous-tone still images: JPEG File Interchange
210
+ Format (JFIF). It is available as a free download in PDF file format from
211
+ https://www.iso.org/standard/54989.html and http://www.itu.int/rec/T-REC-T.871.
212
+ A PDF file of the older JFIF 1.02 specification is available at
213
+ http://www.w3.org/Graphics/JPEG/jfif3.pdf.
214
+
215
+ The TIFF 6.0 file format specification can be obtained from
216
+ http://mirrors.ctan.org/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation
217
+ scheme found in the TIFF 6.0 spec of 3-June-92 has a number of serious
218
+ problems. IJG does not recommend use of the TIFF 6.0 design (TIFF Compression
219
+ tag 6). Instead, we recommend the JPEG design proposed by TIFF Technical Note
220
+ #2 (Compression tag 7). Copies of this Note can be obtained from
221
+ http://www.ijg.org/files/. It is expected that the next revision
222
+ of the TIFF spec will replace the 6.0 JPEG design with the Note's design.
223
+ Although IJG's own code does not support TIFF/JPEG, the free libtiff library
224
+ uses our library to implement TIFF/JPEG per the Note.
225
+
226
+
227
+ ARCHIVE LOCATIONS
228
+ =================
229
+
230
+ The "official" archive site for this software is www.ijg.org.
231
+ The most recent released version can always be found there in
232
+ directory "files".
233
+
234
+ The JPEG FAQ (Frequently Asked Questions) article is a source of some
235
+ general information about JPEG. It is available at
236
+ http://www.faqs.org/faqs/jpeg-faq.
237
+
238
+
239
+ FILE FORMAT COMPATIBILITY
240
+ =========================
241
+
242
+ This software implements ITU T.81 | ISO/IEC 10918 with some extensions from
243
+ ITU T.871 | ISO/IEC 10918-5 (JPEG File Interchange Format-- see REFERENCES).
244
+ Informally, the term "JPEG image" or "JPEG file" most often refers to JFIF or
245
+ a subset thereof, but there are other formats containing the name "JPEG" that
246
+ are incompatible with the original JPEG standard or with JFIF (for instance,
247
+ JPEG 2000 and JPEG XR). This software therefore does not support these
248
+ formats. Indeed, one of the original reasons for developing this free software
249
+ was to help force convergence on a common, interoperable format standard for
250
+ JPEG files.
251
+
252
+ JFIF is a minimal or "low end" representation. TIFF/JPEG (TIFF revision 6.0 as
253
+ modified by TIFF Technical Note #2) can be used for "high end" applications
254
+ that need to record a lot of additional data about an image.
255
+
256
+
257
+ TO DO
258
+ =====
259
+
260
+ Please send bug reports, offers of help, etc. to jpeg-info@jpegclub.org.