-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.go
More file actions
83 lines (82 loc) · 2.15 KB
/
doc.go
File metadata and controls
83 lines (82 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Package imx provides fast, dependency-free extraction of image metadata.
//
// It supports EXIF, IPTC, XMP, and ICC metadata from JPEG, PNG, GIF, WebP,
// TIFF-based formats (including CR2/DNG), HEIC, plus ID3/FLAC/MP4 audio/video tags.
//
// Version: 1.0.0
//
// Basic usage:
//
// meta, err := imx.MetadataFromFile("photo.jpg")
// if err != nil {
// log.Fatal(err)
// }
//
// // Access tags by ID
// if tag, ok := meta.Tag("EXIF:IFD0:Make"); ok {
// fmt.Printf("Camera: %v\n", tag.Value)
// }
//
// // Or use type-safe getters
// make, err := meta.GetString("EXIF:IFD0:Make")
// if err == nil {
// fmt.Printf("Camera: %s\n", make)
// }
//
// For more control, use the Extractor type:
//
// extractor := imx.New(
// imx.WithHTTPTimeout(60 * time.Second), // Set HTTP timeout for URL fetching
// )
//
// meta, err := extractor.MetadataFromFile("photo.jpg")
//
// Iterate over tags:
//
// // All tags across all directories
// meta.Each(func(dir imx.Directory, tag imx.Tag) bool {
// fmt.Printf("[%s] %s = %v\n", dir.Name, tag.Name, tag.Value)
// return true // continue
// })
//
// // Tags in a specific directory
// meta.EachInDirectory("IFD0", func(tag imx.Tag) bool {
// fmt.Printf("%s = %v\n", tag.Name, tag.Value)
// return true
// })
//
// Error handling:
//
// meta, err := imx.MetadataFromFile("photo.jpg")
// if err != nil {
// if errors.Is(err, imx.ErrUnknownFormat) {
// fmt.Println("Unsupported file format")
// } else {
// log.Fatal(err)
// }
// }
//
// // Check for parsing errors
// if len(meta.Errors()) > 0 {
// fmt.Printf("Parsing errors: %v\n", meta.Errors())
// // meta still contains successfully parsed data
// }
//
// Multiple input sources:
//
// // From file with safety limit
// meta, err := imx.MetadataFromFile("photo.jpg", imx.WithMaxBytes(50<<20))
//
// // From byte slice
// data, _ := os.ReadFile("photo.jpg")
// meta, err = imx.MetadataFromBytes(data)
//
// // From io.Reader (buffered on-demand)
// file, _ := os.Open("photo.jpg")
// meta, err = imx.MetadataFromReader(file)
//
// // From URL
// meta, err = imx.MetadataFromURL("https://example.com/photo.jpg")
package imx
// Version is the semantic version of the imx package
const Version = "1.0.0"