cross-image 0.2.3 β†’ 0.2.4

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 (72) hide show
  1. package/README.md +333 -289
  2. package/esm/mod.d.ts +2 -0
  3. package/esm/mod.js +2 -0
  4. package/esm/src/formats/apng.d.ts +13 -1
  5. package/esm/src/formats/apng.js +97 -0
  6. package/esm/src/formats/ascii.d.ts +11 -1
  7. package/esm/src/formats/ascii.js +24 -0
  8. package/esm/src/formats/avif.d.ts +96 -0
  9. package/esm/src/formats/avif.js +607 -0
  10. package/esm/src/formats/bmp.d.ts +11 -1
  11. package/esm/src/formats/bmp.js +73 -0
  12. package/esm/src/formats/dng.d.ts +13 -1
  13. package/esm/src/formats/dng.js +26 -4
  14. package/esm/src/formats/gif.d.ts +15 -2
  15. package/esm/src/formats/gif.js +146 -4
  16. package/esm/src/formats/heic.d.ts +96 -0
  17. package/esm/src/formats/heic.js +608 -0
  18. package/esm/src/formats/ico.d.ts +11 -1
  19. package/esm/src/formats/ico.js +28 -0
  20. package/esm/src/formats/jpeg.d.ts +7 -0
  21. package/esm/src/formats/jpeg.js +76 -0
  22. package/esm/src/formats/pam.d.ts +11 -1
  23. package/esm/src/formats/pam.js +66 -0
  24. package/esm/src/formats/pcx.d.ts +11 -1
  25. package/esm/src/formats/pcx.js +45 -0
  26. package/esm/src/formats/png.d.ts +13 -1
  27. package/esm/src/formats/png.js +87 -0
  28. package/esm/src/formats/ppm.d.ts +11 -1
  29. package/esm/src/formats/ppm.js +34 -0
  30. package/esm/src/formats/tiff.d.ts +7 -0
  31. package/esm/src/formats/tiff.js +134 -0
  32. package/esm/src/formats/webp.d.ts +7 -0
  33. package/esm/src/formats/webp.js +92 -0
  34. package/esm/src/image.d.ts +9 -0
  35. package/esm/src/image.js +28 -0
  36. package/esm/src/types.d.ts +18 -0
  37. package/package.json +18 -1
  38. package/script/mod.d.ts +2 -0
  39. package/script/mod.js +5 -1
  40. package/script/src/formats/apng.d.ts +13 -1
  41. package/script/src/formats/apng.js +97 -0
  42. package/script/src/formats/ascii.d.ts +11 -1
  43. package/script/src/formats/ascii.js +24 -0
  44. package/script/src/formats/avif.d.ts +96 -0
  45. package/script/src/formats/avif.js +611 -0
  46. package/script/src/formats/bmp.d.ts +11 -1
  47. package/script/src/formats/bmp.js +73 -0
  48. package/script/src/formats/dng.d.ts +13 -1
  49. package/script/src/formats/dng.js +26 -4
  50. package/script/src/formats/gif.d.ts +15 -2
  51. package/script/src/formats/gif.js +146 -4
  52. package/script/src/formats/heic.d.ts +96 -0
  53. package/script/src/formats/heic.js +612 -0
  54. package/script/src/formats/ico.d.ts +11 -1
  55. package/script/src/formats/ico.js +28 -0
  56. package/script/src/formats/jpeg.d.ts +7 -0
  57. package/script/src/formats/jpeg.js +76 -0
  58. package/script/src/formats/pam.d.ts +11 -1
  59. package/script/src/formats/pam.js +66 -0
  60. package/script/src/formats/pcx.d.ts +11 -1
  61. package/script/src/formats/pcx.js +45 -0
  62. package/script/src/formats/png.d.ts +13 -1
  63. package/script/src/formats/png.js +87 -0
  64. package/script/src/formats/ppm.d.ts +11 -1
  65. package/script/src/formats/ppm.js +34 -0
  66. package/script/src/formats/tiff.d.ts +7 -0
  67. package/script/src/formats/tiff.js +134 -0
  68. package/script/src/formats/webp.d.ts +7 -0
  69. package/script/src/formats/webp.js +92 -0
  70. package/script/src/image.d.ts +9 -0
  71. package/script/src/image.js +28 -0
  72. package/script/src/types.d.ts +18 -0
package/README.md CHANGED
@@ -1,289 +1,333 @@
1
- # @cross/image
2
-
3
- A pure JavaScript, dependency-free, cross-runtime image processing library for
4
- Deno, Node.js, and Bun. Decode, encode, manipulate, and process images in
5
- multiple formats including PNG, JPEG, WebP, GIF, and moreβ€”all without native
6
- dependencies.
7
-
8
- πŸ“š **[Full Documentation](https://cross-image.56k.guru/)**
9
-
10
- ## Features
11
-
12
- - πŸš€ **Pure JavaScript** - No native dependencies
13
- - πŸ”Œ **Pluggable formats** - Easy to extend with custom formats
14
- - πŸ“¦ **Cross-runtime** - Works on Deno, Node.js (18+), and Bun
15
- - 🎨 **Multiple formats** - PNG, APNG, JPEG, WebP, GIF, TIFF, BMP, ICO, DNG,
16
- PAM, PPM, PCX and ASCII support
17
- - βœ‚οΈ **Image manipulation** - Resize, crop, composite, and more
18
- - πŸŽ›οΈ **Image processing** - Chainable filters including `brightness`,
19
- `contrast`, `saturation`, `hue`, `exposure`, `blur`, `sharpen`, `sepia`, and
20
- more
21
- - πŸ–ŒοΈ **Drawing operations** - Create, fill, and manipulate pixels
22
- - 🧩 **Multi-frame** - Decode/encode animated GIFs, APNGs and multi-page TIFFs
23
- - πŸ”§ **Simple API** - Easy to use, intuitive interface
24
-
25
- ## Installation
26
-
27
- ### Deno
28
-
29
- ```ts
30
- import { Image } from "jsr:@cross/image";
31
- ```
32
-
33
- ### Node.js
34
-
35
- ```bash
36
- npm install cross-image
37
- ```
38
-
39
- ```ts
40
- import { Image } from "cross-image";
41
- ```
42
-
43
- ### Bun
44
-
45
- ```bash
46
- npm install cross-image
47
- ```
48
-
49
- ```ts
50
- import { Image } from "cross-image";
51
- ```
52
-
53
- ## Quick Start
54
-
55
- ### Deno
56
-
57
- ```ts
58
- import { Image } from "@cross/image";
59
-
60
- // Decode an image (auto-detects format)
61
- const data = await Deno.readFile("input.png");
62
- const image = await Image.decode(data);
63
-
64
- console.log(`Image size: ${image.width}x${image.height}`);
65
-
66
- // Create a new blank image
67
- const canvas = Image.create(800, 600, 255, 255, 255); // white background
68
-
69
- // Composite the loaded image on top
70
- canvas.composite(image, 50, 50);
71
-
72
- // Apply image processing filters
73
- canvas
74
- .brightness(0.1)
75
- .contrast(0.2)
76
- .saturation(-0.1)
77
- .blur(1)
78
- .sharpen(0.3);
79
-
80
- // Encode in a different format
81
- const jpeg = await canvas.encode("jpeg");
82
- await Deno.writeFile("output.jpg", jpeg);
83
- ```
84
-
85
- ### Node.js
86
-
87
- ```ts
88
- import { Image } from "cross-image";
89
- import { readFile, writeFile } from "node:fs/promises";
90
-
91
- // Read an image (auto-detects format)
92
- const data = await readFile("input.png");
93
- const image = await Image.decode(data);
94
-
95
- console.log(`Image size: ${image.width}x${image.height}`);
96
-
97
- // Resize the image
98
- image.resize({ width: 800, height: 600 });
99
-
100
- // Save in a different format
101
- const jpeg = await image.encode("jpeg");
102
- await writeFile("output.jpg", jpeg);
103
- ```
104
-
105
- ## Supported Formats
106
-
107
- | Format | Pure-JS | Notes |
108
- | ------ | ----------- | -------------------------------------- |
109
- | PNG | βœ… Full | Complete pure-JS implementation |
110
- | APNG | βœ… Full | Animated PNG with multi-frame |
111
- | BMP | βœ… Full | Complete pure-JS implementation |
112
- | ICO | βœ… Full | Windows Icon format |
113
- | GIF | βœ… Full | Animated GIF with multi-frame |
114
- | DNG | βœ… Full | Linear DNG (Uncompressed RGBA) |
115
- | PAM | βœ… Full | Netpbm PAM format |
116
- | PPM | βœ… Full | Netpbm PPM format (P3/P6) |
117
- | PCX | βœ… Full | ZSoft PCX (RLE compressed) |
118
- | ASCII | βœ… Full | Text-based ASCII art |
119
- | JPEG | ⚠️ Baseline | Pure-JS baseline DCT only |
120
- | WebP | ⚠️ Lossless | Pure-JS lossless VP8L |
121
- | TIFF | ⚠️ Basic | Pure-JS uncompressed, LZW, & grayscale |
122
-
123
- See the
124
- [full format support documentation](https://cross-image.56k.guru/formats/) for
125
- detailed compatibility information.
126
-
127
- ## Metadata Support
128
-
129
- @cross/image provides comprehensive EXIF 3.0 compliant metadata support for
130
- image files, including camera information, GPS coordinates, and InteropIFD
131
- compatibility markers.
132
-
133
- ### Supported Metadata Fields
134
-
135
- **Basic Metadata:**
136
-
137
- - `title`, `description`, `author`, `copyright`
138
- - `creationDate` - Date/time image was created
139
-
140
- **Camera Settings (JPEG, TIFF, WebP via XMP):**
141
-
142
- - `cameraMake`, `cameraModel` - Camera manufacturer and model
143
- - `lensMake`, `lensModel` - Lens information
144
- - `iso` - ISO speed rating
145
- - `exposureTime` - Shutter speed in seconds
146
- - `fNumber` - Aperture (f-number)
147
- - `focalLength` - Focal length in mm
148
- - `flash`, `whiteBalance` - Capture settings
149
- - `orientation` - Image orientation (1=normal, 3=180Β°, 6=90Β°CW, 8=90Β°CCW)
150
- - `software` - Software used
151
- - `userComment` - User notes
152
-
153
- **GPS Coordinates (All EXIF formats: JPEG, PNG, WebP, TIFF):**
154
-
155
- - `latitude`, `longitude` - GPS coordinates in decimal degrees
156
- - Full microsecond precision with DMS (degrees-minutes-seconds) conversion
157
-
158
- **DPI (JPEG, PNG, TIFF):**
159
-
160
- - `dpiX`, `dpiY` - Dots per inch for printing
161
-
162
- ### EXIF 3.0 Specification Compliance
163
-
164
- The library implements the EXIF 3.0 specification with:
165
-
166
- - **50+ Exif Sub-IFD tags** for comprehensive camera metadata
167
- - **30+ IFD0 tags** for image information
168
- - **InteropIFD support** for format compatibility (R98/sRGB, R03/Adobe RGB,
169
- THM/thumbnail)
170
- - **GPS IFD** with proper coordinate conversion
171
- - All EXIF data types (BYTE, ASCII, SHORT, LONG, RATIONAL, etc.)
172
-
173
- ### Example Usage
174
-
175
- ```typescript
176
- import { Image } from "@cross/image";
177
-
178
- // Load an image
179
- const data = await Deno.readFile("photo.jpg");
180
- const image = await Image.decode(data);
181
-
182
- // Set metadata
183
- image.setMetadata({
184
- author: "Jane Photographer",
185
- copyright: "Β© 2024",
186
- cameraMake: "Canon",
187
- cameraModel: "EOS R5",
188
- iso: 800,
189
- exposureTime: 0.004, // 1/250s
190
- fNumber: 2.8,
191
- focalLength: 50,
192
- });
193
-
194
- // Set GPS coordinates
195
- image.setPosition(40.7128, -74.0060); // NYC
196
-
197
- // Check what metadata a format supports
198
- const jpegSupports = Image.getSupportedMetadata("jpeg");
199
- console.log(jpegSupports); // Includes ISO, camera info, GPS, etc.
200
-
201
- // Save with metadata
202
- const jpeg = await image.save("jpeg");
203
- await Deno.writeFile("output.jpg", jpeg);
204
-
205
- // Metadata is preserved on reload!
206
- const loaded = await Image.decode(jpeg);
207
- console.log(loaded.metadata?.cameraMake); // "Canon"
208
- console.log(loaded.getPosition()); // { latitude: 40.7128, longitude: -74.0060 }
209
- ```
210
-
211
- ### Format-Specific Support
212
-
213
- Use `Image.getSupportedMetadata(format)` to check which fields are supported:
214
-
215
- ```typescript
216
- Image.getSupportedMetadata("jpeg"); // Full camera metadata + GPS (21 fields)
217
- Image.getSupportedMetadata("tiff"); // Comprehensive EXIF + GPS + InteropIFD (23+ fields)
218
- Image.getSupportedMetadata("png"); // DateTime, GPS, DPI, basic text (9 fields)
219
- Image.getSupportedMetadata("webp"); // Enhanced XMP + GPS (15 fields - includes camera metadata!)
220
- ```
221
-
222
- **Format Highlights:**
223
-
224
- - **JPEG**: Most comprehensive EXIF support, including all camera settings and
225
- GPS
226
- - **TIFF**: Full EXIF 3.0 support with IFD structure, InteropIFD compatibility
227
- - **WebP**: Enhanced XMP implementation with Dublin Core, EXIF, and TIFF
228
- namespaces
229
- - **PNG**: Basic EXIF support via eXIf chunk plus GPS coordinates
230
-
231
- ## Documentation
232
-
233
- - **[API Reference](https://cross-image.56k.guru/api/)** - Complete API
234
- documentation
235
- - **[Format Support](https://cross-image.56k.guru/formats/)** - Supported
236
- formats and specifications
237
- - **[Image Processing](https://cross-image.56k.guru/processing/)** - Filters,
238
- manipulation, and color adjustments
239
- - [Filters](https://cross-image.56k.guru/processing/filters/) - Blur, sharpen,
240
- and noise reduction
241
- - [Manipulation](https://cross-image.56k.guru/processing/manipulation/) -
242
- Resize, crop, composite, and draw
243
- - [Color Adjustments](https://cross-image.56k.guru/processing/color-adjustments/) -
244
- Brightness, contrast, saturation, and more
245
- - **[Examples](https://cross-image.56k.guru/examples/)** - Practical examples
246
- for common tasks
247
- - [Decoding & Encoding](https://cross-image.56k.guru/examples/decoding-encoding/) -
248
- Format-specific examples
249
- - [Using Filters](https://cross-image.56k.guru/examples/filters/) - Filter
250
- workflows and techniques
251
- - [Manipulation](https://cross-image.56k.guru/examples/manipulation/) -
252
- Resizing, cropping, and compositing
253
- - [Multi-Frame Images](https://cross-image.56k.guru/examples/multi-frame/) -
254
- Animated GIFs, APNGs, and TIFFs
255
- - **[JPEG Implementation](https://cross-image.56k.guru/implementation/jpeg-implementation/)** -
256
- Technical details for JPEG
257
- - **[WebP Implementation](https://cross-image.56k.guru/implementation/webp-implementation/)** -
258
- Technical details for WebP
259
- - **[TIFF Implementation](https://cross-image.56k.guru/implementation/tiff-implementation/)** -
260
- Technical details for TIFF
261
-
262
- ## Development
263
-
264
- ### Running Tests
265
-
266
- ```bash
267
- deno test -A
268
- ```
269
-
270
- ### Linting and Formatting
271
-
272
- ```bash
273
- deno fmt --check
274
- deno lint
275
- ```
276
-
277
- ### Type Checking
278
-
279
- ```bash
280
- deno check mod.ts
281
- ```
282
-
283
- ## License
284
-
285
- MIT License - see LICENSE file for details.
286
-
287
- ## Contributing
288
-
289
- Contributions are welcome! Please feel free to submit a Pull Request.
1
+ # @cross/image
2
+
3
+ A pure JavaScript, dependency-free, cross-runtime image processing library for
4
+ Deno, Node.js, and Bun. Decode, encode, manipulate, and process images in
5
+ multiple formats including PNG, JPEG, WebP, GIF, and moreβ€”all without native
6
+ dependencies.
7
+
8
+ πŸ“š **[Full Documentation](https://cross-image.56k.guru/)**
9
+
10
+ ## Features
11
+
12
+ - πŸš€ **Pure JavaScript** - No native dependencies
13
+ - πŸ”Œ **Pluggable formats** - Easy to extend with custom formats
14
+ - πŸ“¦ **Cross-runtime** - Works on Deno, Node.js (18+), and Bun
15
+ - 🎨 **Multiple formats** - PNG, APNG, JPEG, WebP, GIF, TIFF, BMP, ICO, DNG,
16
+ PAM, PPM, PCX, ASCII, HEIC, and AVIF support
17
+ - βœ‚οΈ **Image manipulation** - Resize, crop, composite, and more
18
+ - πŸŽ›οΈ **Image processing** - Chainable filters including `brightness`,
19
+ `contrast`, `saturation`, `hue`, `exposure`, `blur`, `sharpen`, `sepia`, and
20
+ more
21
+ - πŸ–ŒοΈ **Drawing operations** - Create, fill, and manipulate pixels
22
+ - 🧩 **Multi-frame** - Decode/encode animated GIFs, APNGs and multi-page TIFFs
23
+ - πŸ”§ **Simple API** - Easy to use, intuitive interface
24
+
25
+ ## Installation
26
+
27
+ ### Deno
28
+
29
+ ```ts
30
+ import { Image } from "jsr:@cross/image";
31
+ ```
32
+
33
+ ### Node.js
34
+
35
+ ```bash
36
+ npm install cross-image
37
+ ```
38
+
39
+ ```ts
40
+ import { Image } from "cross-image";
41
+ ```
42
+
43
+ ### Bun
44
+
45
+ ```bash
46
+ npm install cross-image
47
+ ```
48
+
49
+ ```ts
50
+ import { Image } from "cross-image";
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ ### Deno
56
+
57
+ ```ts
58
+ import { Image } from "@cross/image";
59
+
60
+ // Decode an image (auto-detects format)
61
+ const data = await Deno.readFile("input.png");
62
+ const image = await Image.decode(data);
63
+
64
+ console.log(`Image size: ${image.width}x${image.height}`);
65
+
66
+ // Create a new blank image
67
+ const canvas = Image.create(800, 600, 255, 255, 255); // white background
68
+
69
+ // Composite the loaded image on top
70
+ canvas.composite(image, 50, 50);
71
+
72
+ // Apply image processing filters
73
+ canvas
74
+ .brightness(0.1)
75
+ .contrast(0.2)
76
+ .saturation(-0.1)
77
+ .blur(1)
78
+ .sharpen(0.3);
79
+
80
+ // Encode in a different format
81
+ const jpeg = await canvas.encode("jpeg");
82
+ await Deno.writeFile("output.jpg", jpeg);
83
+ ```
84
+
85
+ ### Node.js
86
+
87
+ ```ts
88
+ import { Image } from "cross-image";
89
+ import { readFile, writeFile } from "node:fs/promises";
90
+
91
+ // Read an image (auto-detects format)
92
+ const data = await readFile("input.png");
93
+ const image = await Image.decode(data);
94
+
95
+ console.log(`Image size: ${image.width}x${image.height}`);
96
+
97
+ // Resize the image
98
+ image.resize({ width: 800, height: 600 });
99
+
100
+ // Save in a different format
101
+ const jpeg = await image.encode("jpeg");
102
+ await writeFile("output.jpg", jpeg);
103
+ ```
104
+
105
+ ## Supported Formats
106
+
107
+ | Format | Pure-JS | Notes |
108
+ | ------ | ----------- | ------------------------------------------------- |
109
+ | PNG | βœ… Full | Complete pure-JS implementation |
110
+ | APNG | βœ… Full | Animated PNG with multi-frame |
111
+ | BMP | βœ… Full | Complete pure-JS implementation |
112
+ | ICO | βœ… Full | Windows Icon format |
113
+ | GIF | βœ… Full | Animated GIF with multi-frame |
114
+ | DNG | βœ… Full | Linear DNG (Uncompressed RGBA) |
115
+ | PAM | βœ… Full | Netpbm PAM format |
116
+ | PPM | βœ… Full | Netpbm PPM format (P3/P6) |
117
+ | PCX | βœ… Full | ZSoft PCX (RLE compressed) |
118
+ | ASCII | βœ… Full | Text-based ASCII art |
119
+ | JPEG | ⚠️ Baseline | Pure-JS baseline DCT only |
120
+ | WebP | ⚠️ Lossless | Pure-JS lossless VP8L |
121
+ | TIFF | ⚠️ Basic | Pure-JS uncompressed, LZW, & grayscale |
122
+ | HEIC | πŸ”Œ Runtime | Requires ImageDecoder/OffscreenCanvas API support |
123
+ | AVIF | πŸ”Œ Runtime | Requires ImageDecoder/OffscreenCanvas API support |
124
+
125
+ See the
126
+ [full format support documentation](https://cross-image.56k.guru/formats/) for
127
+ detailed compatibility information.
128
+
129
+ ## Metadata Support
130
+
131
+ @cross/image provides comprehensive EXIF 3.0 compliant metadata support for
132
+ image files, including camera information, GPS coordinates, and InteropIFD
133
+ compatibility markers.
134
+
135
+ ### Supported Metadata Fields
136
+
137
+ **Basic Metadata:**
138
+
139
+ - `title`, `description`, `author`, `copyright`
140
+ - `creationDate` - Date/time image was created
141
+
142
+ **Camera Settings (JPEG, TIFF, WebP via XMP):**
143
+
144
+ - `cameraMake`, `cameraModel` - Camera manufacturer and model
145
+ - `lensMake`, `lensModel` - Lens information
146
+ - `iso` - ISO speed rating
147
+ - `exposureTime` - Shutter speed in seconds
148
+ - `fNumber` - Aperture (f-number)
149
+ - `focalLength` - Focal length in mm
150
+ - `flash`, `whiteBalance` - Capture settings
151
+ - `orientation` - Image orientation (1=normal, 3=180Β°, 6=90Β°CW, 8=90Β°CCW)
152
+ - `software` - Software used
153
+ - `userComment` - User notes
154
+
155
+ **GPS Coordinates (All EXIF formats: JPEG, PNG, WebP, TIFF):**
156
+
157
+ - `latitude`, `longitude` - GPS coordinates in decimal degrees
158
+ - Full microsecond precision with DMS (degrees-minutes-seconds) conversion
159
+
160
+ **DPI (JPEG, PNG, TIFF):**
161
+
162
+ - `dpiX`, `dpiY` - Dots per inch for printing
163
+
164
+ ### EXIF 3.0 Specification Compliance
165
+
166
+ The library implements the EXIF 3.0 specification with:
167
+
168
+ - **50+ Exif Sub-IFD tags** for comprehensive camera metadata
169
+ - **30+ IFD0 tags** for image information
170
+ - **InteropIFD support** for format compatibility (R98/sRGB, R03/Adobe RGB,
171
+ THM/thumbnail)
172
+ - **GPS IFD** with proper coordinate conversion
173
+ - All EXIF data types (BYTE, ASCII, SHORT, LONG, RATIONAL, etc.)
174
+
175
+ ### Example Usage
176
+
177
+ ```typescript
178
+ import { Image } from "@cross/image";
179
+
180
+ // Load an image
181
+ const data = await Deno.readFile("photo.jpg");
182
+ const image = await Image.decode(data);
183
+
184
+ // Set metadata
185
+ image.setMetadata({
186
+ author: "Jane Photographer",
187
+ copyright: "Β© 2024",
188
+ cameraMake: "Canon",
189
+ cameraModel: "EOS R5",
190
+ iso: 800,
191
+ exposureTime: 0.004, // 1/250s
192
+ fNumber: 2.8,
193
+ focalLength: 50,
194
+ });
195
+
196
+ // Set GPS coordinates
197
+ image.setPosition(40.7128, -74.0060); // NYC
198
+
199
+ // Check what metadata a format supports
200
+ const jpegSupports = Image.getSupportedMetadata("jpeg");
201
+ console.log(jpegSupports); // Includes ISO, camera info, GPS, etc.
202
+
203
+ // Save with metadata
204
+ const jpeg = await image.save("jpeg");
205
+ await Deno.writeFile("output.jpg", jpeg);
206
+
207
+ // Metadata is preserved on reload!
208
+ const loaded = await Image.decode(jpeg);
209
+ console.log(loaded.metadata?.cameraMake); // "Canon"
210
+ console.log(loaded.getPosition()); // { latitude: 40.7128, longitude: -74.0060 }
211
+ ```
212
+
213
+ ### Extracting Metadata Without Decoding
214
+
215
+ For quickly reading metadata from images without the overhead of decoding pixel
216
+ data, use `Image.extractMetadata()`. This is particularly useful for:
217
+
218
+ - Reading EXIF data from large images or photos
219
+ - Extracting metadata from images with unsupported compression
220
+ - Building image catalogs or galleries
221
+ - Processing metadata in batch operations
222
+
223
+ ```typescript
224
+ import { Image } from "@cross/image";
225
+
226
+ // Extract metadata without decoding pixels
227
+ const data = await Deno.readFile("large-photo.jpg");
228
+ const metadata = await Image.extractMetadata(data);
229
+
230
+ console.log(metadata?.cameraMake); // "Canon"
231
+ console.log(metadata?.iso); // 800
232
+ console.log(metadata?.exposureTime); // 0.004
233
+
234
+ // Works with auto-detection
235
+ const metadata2 = await Image.extractMetadata(data); // Detects JPEG
236
+
237
+ // Or specify format explicitly
238
+ const metadata3 = await Image.extractMetadata(data, "jpeg");
239
+ ```
240
+
241
+ This method is significantly faster than full decode when you only need
242
+ metadata, as it:
243
+
244
+ - Skips pixel data decompression
245
+ - Only parses metadata chunks/markers
246
+ - Returns `undefined` for unsupported formats
247
+ - Works with JPEG, PNG, WebP, TIFF, HEIC, and AVIF formats
248
+
249
+ ### Format-Specific Support
250
+
251
+ Use `Image.getSupportedMetadata(format)` to check which fields are supported:
252
+
253
+ ```typescript
254
+ Image.getSupportedMetadata("jpeg"); // Full camera metadata + GPS (21 fields)
255
+ Image.getSupportedMetadata("tiff"); // Comprehensive EXIF + GPS + InteropIFD (23+ fields)
256
+ Image.getSupportedMetadata("png"); // DateTime, GPS, DPI, basic text (9 fields)
257
+ Image.getSupportedMetadata("webp"); // Enhanced XMP + GPS (15 fields - includes camera metadata!)
258
+ Image.getSupportedMetadata("heic"); // Full camera metadata + GPS (19 fields)
259
+ Image.getSupportedMetadata("avif"); // Full camera metadata + GPS (19 fields)
260
+ ```
261
+
262
+ **Format Highlights:**
263
+
264
+ - **JPEG**: Most comprehensive EXIF support, including all camera settings and
265
+ GPS
266
+ - **TIFF**: Full EXIF 3.0 support with IFD structure, InteropIFD compatibility
267
+ - **WebP**: Enhanced XMP implementation with Dublin Core, EXIF, and TIFF
268
+ namespaces
269
+ - **PNG**: Basic EXIF support via eXIf chunk plus GPS coordinates
270
+ - **HEIC**: Full EXIF metadata extraction including camera settings, GPS, and
271
+ image info (runtime-dependent encoding)
272
+ - **AVIF**: Full EXIF metadata extraction including camera settings, GPS, and
273
+ image info (runtime-dependent encoding)
274
+
275
+ ## Documentation
276
+
277
+ - **[API Reference](https://cross-image.56k.guru/api/)** - Complete API
278
+ documentation
279
+ - **[Format Support](https://cross-image.56k.guru/formats/)** - Supported
280
+ formats and specifications
281
+ - **[Image Processing](https://cross-image.56k.guru/processing/)** - Filters,
282
+ manipulation, and color adjustments
283
+ - [Filters](https://cross-image.56k.guru/processing/filters/) - Blur, sharpen,
284
+ and noise reduction
285
+ - [Manipulation](https://cross-image.56k.guru/processing/manipulation/) -
286
+ Resize, crop, composite, and draw
287
+ - [Color Adjustments](https://cross-image.56k.guru/processing/color-adjustments/) -
288
+ Brightness, contrast, saturation, and more
289
+ - **[Examples](https://cross-image.56k.guru/examples/)** - Practical examples
290
+ for common tasks
291
+ - [Decoding & Encoding](https://cross-image.56k.guru/examples/decoding-encoding/) -
292
+ Format-specific examples
293
+ - [Using Filters](https://cross-image.56k.guru/examples/filters/) - Filter
294
+ workflows and techniques
295
+ - [Manipulation](https://cross-image.56k.guru/examples/manipulation/) -
296
+ Resizing, cropping, and compositing
297
+ - [Multi-Frame Images](https://cross-image.56k.guru/examples/multi-frame/) -
298
+ Animated GIFs, APNGs, and TIFFs
299
+ - **[JPEG Implementation](https://cross-image.56k.guru/implementation/jpeg-implementation/)** -
300
+ Technical details for JPEG
301
+ - **[WebP Implementation](https://cross-image.56k.guru/implementation/webp-implementation/)** -
302
+ Technical details for WebP
303
+ - **[TIFF Implementation](https://cross-image.56k.guru/implementation/tiff-implementation/)** -
304
+ Technical details for TIFF
305
+
306
+ ## Development
307
+
308
+ ### Running Tests
309
+
310
+ ```bash
311
+ deno test -A
312
+ ```
313
+
314
+ ### Linting and Formatting
315
+
316
+ ```bash
317
+ deno fmt --check
318
+ deno lint
319
+ ```
320
+
321
+ ### Type Checking
322
+
323
+ ```bash
324
+ deno check mod.ts
325
+ ```
326
+
327
+ ## License
328
+
329
+ MIT License - see LICENSE file for details.
330
+
331
+ ## Contributing
332
+
333
+ Contributions are welcome! Please feel free to submit a Pull Request.
package/esm/mod.d.ts CHANGED
@@ -57,4 +57,6 @@ export { PAMFormat } from "./src/formats/pam.js";
57
57
  export { PCXFormat } from "./src/formats/pcx.js";
58
58
  export { PPMFormat } from "./src/formats/ppm.js";
59
59
  export { ASCIIFormat } from "./src/formats/ascii.js";
60
+ export { HEICFormat } from "./src/formats/heic.js";
61
+ export { AVIFFormat } from "./src/formats/avif.js";
60
62
  //# sourceMappingURL=mod.d.ts.map
package/esm/mod.js CHANGED
@@ -56,3 +56,5 @@ export { PAMFormat } from "./src/formats/pam.js";
56
56
  export { PCXFormat } from "./src/formats/pcx.js";
57
57
  export { PPMFormat } from "./src/formats/ppm.js";
58
58
  export { ASCIIFormat } from "./src/formats/ascii.js";
59
+ export { HEICFormat } from "./src/formats/heic.js";
60
+ export { AVIFFormat } from "./src/formats/avif.js";