Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mike10004/jpeg-segment-finder
Java library to determine the offsets and lengths of metadata segments in a JPEG file.
https://github.com/mike10004/jpeg-segment-finder
Last synced: 15 days ago
JSON representation
Java library to determine the offsets and lengths of metadata segments in a JPEG file.
- Host: GitHub
- URL: https://github.com/mike10004/jpeg-segment-finder
- Owner: mike10004
- License: apache-2.0
- Created: 2017-11-16T22:36:55.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-26T17:19:57.000Z (over 3 years ago)
- Last Synced: 2024-10-07T09:21:16.004Z (3 months ago)
- Language: Java
- Size: 211 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Travis build status](https://img.shields.io/travis/mike10004/jpeg-segment-finder.svg)](https://travis-ci.org/mike10004/jpeg-segment-finder)
[![Maven Central](https://img.shields.io/maven-central/v/com.github.mike10004/jpeg-segment-finder.svg)](https://repo1.maven.org/maven2/com/github/mike10004/jpeg-segment-finder/)# jpeg-segment-finder
Java library to determine the offsets and lengths of metadata segments in
a JPEG file. This library is intended to be small and not pull in a lot of
external dependencies. Use it if you want to *parse* JPEG metadata yourself
but don't want to *find* JPEG metadata yourself.## Maven
com.github.mike10004
jpeg-segment-finder
0.5
## Usage
Find IPTC segments marked by byte 0xED:
JpegSegmentFinder finder = new JpegSegmentFinder();
List segments;
try (InputStream in = new FileInputStream(jpegFile)) {
segments = finder.findSegments(in, Collections.singleton((byte) 0xED));
}
JpegSegmentSpec iptc = segments.get(0);
byte[] jpegBytes = Files.readAllBytes(jpegFile.toPath());
int from = (int) iptc.contentOffset;
int to = from + (int) iptc.contentLength;
byte[] segmentBytes = Arrays.copyOfRange(jpegBytes, from, to);
// ...analyze those segments bytes as you please...## Credits
Thank you to Drew Noakes for [metadata-extractor][metadata-extractor]. This
library is a hack on some classes in that library. The test image is from
that project's test resources.[metadata-extractor]: https://github.com/drewnoakes/metadata-extractor