cross-image 0.2.2 → 0.2.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/README.md +128 -7
- package/esm/src/formats/jpeg.d.ts +12 -1
- package/esm/src/formats/jpeg.js +633 -4
- package/esm/src/formats/png_base.d.ts +8 -0
- package/esm/src/formats/png_base.js +176 -3
- package/esm/src/formats/tiff.d.ts +6 -1
- package/esm/src/formats/tiff.js +31 -0
- package/esm/src/formats/webp.d.ts +9 -2
- package/esm/src/formats/webp.js +211 -62
- package/esm/src/image.d.ts +51 -0
- package/esm/src/image.js +225 -5
- package/esm/src/types.d.ts +41 -1
- package/esm/src/utils/image_processing.d.ts +55 -0
- package/esm/src/utils/image_processing.js +210 -0
- package/esm/src/utils/metadata/xmp.d.ts +52 -0
- package/esm/src/utils/metadata/xmp.js +325 -0
- package/esm/src/utils/resize.d.ts +4 -0
- package/esm/src/utils/resize.js +74 -0
- package/package.json +1 -1
- package/script/src/formats/jpeg.d.ts +12 -1
- package/script/src/formats/jpeg.js +633 -4
- package/script/src/formats/png_base.d.ts +8 -0
- package/script/src/formats/png_base.js +176 -3
- package/script/src/formats/tiff.d.ts +6 -1
- package/script/src/formats/tiff.js +31 -0
- package/script/src/formats/webp.d.ts +9 -2
- package/script/src/formats/webp.js +211 -62
- package/script/src/image.d.ts +51 -0
- package/script/src/image.js +223 -3
- package/script/src/types.d.ts +41 -1
- package/script/src/utils/image_processing.d.ts +55 -0
- package/script/src/utils/image_processing.js +216 -0
- package/script/src/utils/metadata/xmp.d.ts +52 -0
- package/script/src/utils/metadata/xmp.js +333 -0
- package/script/src/utils/resize.d.ts +4 -0
- package/script/src/utils/resize.js +75 -0
package/README.md
CHANGED
|
@@ -16,7 +16,8 @@ dependencies.
|
|
|
16
16
|
PAM, PPM, PCX and ASCII support
|
|
17
17
|
- ✂️ **Image manipulation** - Resize, crop, composite, and more
|
|
18
18
|
- 🎛️ **Image processing** - Chainable filters including `brightness`,
|
|
19
|
-
`contrast`, `saturation`, `exposure`, `blur`, `sharpen`, `sepia`, and
|
|
19
|
+
`contrast`, `saturation`, `hue`, `exposure`, `blur`, `sharpen`, `sepia`, and
|
|
20
|
+
more
|
|
20
21
|
- 🖌️ **Drawing operations** - Create, fill, and manipulate pixels
|
|
21
22
|
- 🧩 **Multi-frame** - Decode/encode animated GIFs, APNGs and multi-page TIFFs
|
|
22
23
|
- 🔧 **Simple API** - Easy to use, intuitive interface
|
|
@@ -32,21 +33,21 @@ import { Image } from "jsr:@cross/image";
|
|
|
32
33
|
### Node.js
|
|
33
34
|
|
|
34
35
|
```bash
|
|
35
|
-
|
|
36
|
+
npm install cross-image
|
|
36
37
|
```
|
|
37
38
|
|
|
38
39
|
```ts
|
|
39
|
-
import { Image } from "
|
|
40
|
+
import { Image } from "cross-image";
|
|
40
41
|
```
|
|
41
42
|
|
|
42
43
|
### Bun
|
|
43
44
|
|
|
44
45
|
```bash
|
|
45
|
-
|
|
46
|
+
npm install cross-image
|
|
46
47
|
```
|
|
47
48
|
|
|
48
49
|
```ts
|
|
49
|
-
import { Image } from "
|
|
50
|
+
import { Image } from "cross-image";
|
|
50
51
|
```
|
|
51
52
|
|
|
52
53
|
## Quick Start
|
|
@@ -123,14 +124,134 @@ See the
|
|
|
123
124
|
[full format support documentation](https://cross-image.56k.guru/formats/) for
|
|
124
125
|
detailed compatibility information.
|
|
125
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
|
+
|
|
126
231
|
## Documentation
|
|
127
232
|
|
|
128
233
|
- **[API Reference](https://cross-image.56k.guru/api/)** - Complete API
|
|
129
234
|
documentation
|
|
130
|
-
- **[Examples](https://cross-image.56k.guru/examples/)** - Usage examples for
|
|
131
|
-
common tasks
|
|
132
235
|
- **[Format Support](https://cross-image.56k.guru/formats/)** - Supported
|
|
133
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
|
|
134
255
|
- **[JPEG Implementation](https://cross-image.56k.guru/implementation/jpeg-implementation/)** -
|
|
135
256
|
Technical details for JPEG
|
|
136
257
|
- **[WebP Implementation](https://cross-image.56k.guru/implementation/webp-implementation/)** -
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ImageData, ImageFormat } from "../types.js";
|
|
1
|
+
import type { ImageData, ImageFormat, ImageMetadata } from "../types.js";
|
|
2
2
|
/**
|
|
3
3
|
* JPEG format handler
|
|
4
4
|
* Implements a basic JPEG decoder and encoder
|
|
@@ -30,6 +30,17 @@ export declare class JPEGFormat implements ImageFormat {
|
|
|
30
30
|
private decodeUsingRuntime;
|
|
31
31
|
private parseJFIF;
|
|
32
32
|
private parseEXIF;
|
|
33
|
+
private parseExifSubIFD;
|
|
34
|
+
private parseGPSIFD;
|
|
35
|
+
private readRational;
|
|
33
36
|
private createEXIFData;
|
|
37
|
+
private createGPSIFD;
|
|
38
|
+
private createExifSubIFD;
|
|
39
|
+
private toRational;
|
|
40
|
+
private writeRational;
|
|
41
|
+
/**
|
|
42
|
+
* Get the list of metadata fields supported by JPEG format
|
|
43
|
+
*/
|
|
44
|
+
getSupportedMetadata(): Array<keyof ImageMetadata>;
|
|
34
45
|
}
|
|
35
46
|
//# sourceMappingURL=jpeg.d.ts.map
|