dragon66 / pixymeta Goto Github PK
View Code? Open in Web Editor NEWJava image metadata manipulation tool
License: Eclipse Public License 1.0
Java image metadata manipulation tool
License: Eclipse Public License 1.0
Currently, inserting of metadata to JPEG is put right before SOS segment. This is working but it's not completely conforming to the JPEG EXIF standard.
There are two reasons why the metadata are put right before the SOS segment: first, we need to read all the old metadata until the SOS segment and perhaps do update to the old data and we are only confident to assume that there would be no more metadata after the SOS segment starts; second, we are reading and writing the image simultaneously, this makes it's hard to put the metadata say after SOI, or APP0.
There is a workaround though for this issue: read the segments to a list or map until SOS, do the necessary manipulation, then write them back to a new stream along with the remaining data after the SOS segment. This way, we'll definitely need more memory but it will conform to spec.
the lib works perfect on win7-64 with the demo using
> java -Dfile.encoding=UTF-8 -classpath pixymeta.jar;slf4j-api-1.7.12.jar;slf4j-log4j12-1.7.12.jar;jai_imageio.jar;log4j-1.2.17.jar pixy.test.TestPixyMeta ./images/cmykjpg.jpg
if you copy the images to `pixymeta\lib\images folder
However if i replace the provided jai_imageio.jar
with the current jai_imageio-core-1.3.1.jar
i get
java.lang.NullPointerException
at pixy.util.MetadataUtils.createThumbnail(Unknown Source)
at pixy.test.TestPixyMeta.createThumbnail(Unknown Source)
at pixy.test.TestPixyMeta.main(Unknown Source)
when calling
fin = new FileInputStream("images/f1.tif"); fout = new FileOutputStream("f1-irbthumbnail-inserted.tif"); Metadata.insertIRBThumbnail(fin, fout, createThumbnail("images/f1.tif"));
I assume that jai_imageio.jar
corresponds to
'com.sun.media:jai_imageio:1.1' which is not available any more due to jpeg200-copyright problems
Do you know any free imageio lib that let all tests pass?
I also tried to use com.twelvemonkeys.imageio:imageio-tiff:3.2.1 and got
java.lang.NegativeArraySizeException
at pixy.meta.png.PNGMeta.readChunks(PNGMeta.java:192)
at pixy.meta.png.PNGMeta.insertChunks(PNGMeta.java:74)
at pixy.meta.png.PNGMeta.insertComments(PNGMeta.java:99)
at pixy.meta.Metadata.insertComments(Metadata.java:134)
when calling
fin = new FileInputStream("images/butterfly.png");
fout = new FileOutputStream("comment-inserted.png");
Metadata.insertComments(fin, fout, Arrays.asList("Comment1", "Comment2"));
Hi, is there any plan to release non-SNAPSHOT version anytime soon?
I'm curious to know why you chose the EPL license instead of Apache 2. Also, what factors are important to you when someone forks your project?
I want to obtain the image width and length from the JPEG directory, but pixy.meta.jpeg.JFIF
has no field for that and also no method to get it.
I currently use metadata-extractor to access this field using JpegDirectory
.
See this class: https://github.com/drewnoakes/metadata-extractor/blob/5773aa0e2877d5bafb091c6cbccb550ad2a58479/Source/com/drew/metadata/jpeg/JpegDirectory.java
I tried TiffTag.IMAGE_WIDTH
, TiffTag.IMAGE_LENGTH
, ExifTag.EXIF_IMAGE_WIDTH
and ExifTag.EXIF_IMAGE_HEIGHT
of MetadataType.EXIF
, but these fields sometimes are null
.
How to access these fields?
It's frame height and width of the SOF0 segment. It looks like that this is not made available as metadata.
Replace legacy console output with slf4j logging
I got an original.jpg which I modified by calling addImageField()
and Metadata.insertExif()
.
This is my Kotlin code:
val metadata = Metadata.readMetadata(bytes.inputStream())
val exif = metadata[MetadataType.EXIF] as? Exif
exif?.addImageField(TiffTag.ORIENTATION, FieldType.SHORT, shortArrayOf(4))
Metadata.insertExif(
bytes.inputStream(),
File("modified.jpg").outputStream(),
exif,
true
)
The resulting file is modified.jpg.
Comparing these with ExifTool I spot two problems:
To properly convert ExifTag.DATE_TIME_ORIGINAL to milliseconds we need to read the time zone flag (see 0x9011 on https://exiftool.org/TagNames/EXIF.html). This seems to be missing.
I just cloned the repo (git clone https://github.com/dragon66/pixymeta.git)
Opened it in Eclipse Proton
Tried to Run TestPixyMeta.java
I get the error
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at pixy.test.TestPixyMeta.test(TestPixyMeta.java:51)
Line 51 is:
Map<MetadataType, Metadata> metadataMap = Metadata.readMetadata(args[0]);
Looks like it is expecting argments and found none.
None are defined in Run Configurations.
What are appropriate arguments?
For metadata parsing of cloud files I only download the JPEG header.
I can read the metadata of this file using https://github.com/drewnoakes/metadata-extractor and https://github.com/apache/commons-imaging
If I try to read this file with pixymeta I get an error:
Caused by: java.io.IOException: Premature end of SOS segment!
at pixy.meta.jpeg.JPGMeta.readSOS(Unknown Source)
at pixy.meta.jpeg.JPGMeta.readMetadata(Unknown Source)
at pixy.meta.Metadata.readMetadata(Unknown Source)
Does this library try to read more than just the header? Why?
It would be way more efficient to stop reading from the inputStream when the section with header bytes are processed.
Here is a sample file:
testphoto.jpg
Hi Dragon66,
I'm getting this error recently while invoking pixy.meta.MetadataMetadata.readMetadata(file):
java.lang.UnsupportedClassVersionError: pixy/meta/Metadata : Unsupported major.minor version 52.0
Does it mean that pixy does not support Java 1.7 anymore?
Any help would be appreciated.
I'm curious, could you provide information about the JPEG Ducky dataset? I tried looking it up but couldn't find any information.
Where is it used?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.