Comments (7)
I've been experimenting here and I don't see problems quite as bad as the ones you have.
For example, before processing:
$ exif img_0075.jpg
EXIF tags in 'img_0075.jpg' ('Intel' byte order):
--------------------+----------------------------------------------------------
Tag |Value
--------------------+----------------------------------------------------------
Manufacturer |Canon
Model |Canon DIGITAL IXUS 300
Orientation |Top-left
X-Resolution |180
Y-Resolution |180
Resolution Unit |Inch
Date and Time |2001:10:22 10:00:09
YCbCr Positioning |Centred
Compression |JPEG compression
X-Resolution |180
Y-Resolution |180
Resolution Unit |Inch
Exposure Time |1/800 sec.
F-Number |f/4.7
Exif Version |Exif Version 2.1
Date and Time (Origi|2001:10:22 10:00:09
Date and Time (Digit|2001:10:22 10:00:09
Components Configura|Y Cb Cr -
Compressed Bits per | 2
Shutter Speed |9.66 EV (1/806 sec.)
Aperture |4.53 EV (f/4.8)
Exposure Bias |0.00 EV
Maximum Aperture Val|2.87 EV (f/2.7)
Subject Distance |65.5 m
Metering Mode |Pattern
Flash |Flash did not fire
Focal Length |16.2 mm
Maker Note |410 bytes undefined data
User Comment |
FlashPixVersion |FlashPix Version 1.0
Colour Space |sRGB
Pixel X Dimension |1600
Pixel Y Dimension |1200
Focal Plane X-Resolu|7766.990
Focal Plane Y-Resolu|7741.935
Focal Plane Resoluti|Inch
Sensing Method |One-chip colour area sensor
File Source |DSC
Interoperability Ind|R98
Interoperability Ver|0100
RelatedImageWidth |1600
RelatedImageLength |1200
--------------------+----------------------------------------------------------
EXIF data contains a thumbnail (4098 bytes).
And after:
$ exif tn_img_0075.jpg
EXIF tags in 'tn_img_0075.jpg' ('Intel' byte order):
--------------------+----------------------------------------------------------
Tag |Value
--------------------+----------------------------------------------------------
Manufacturer |Canon
Model |Canon DIGITAL IXUS 300
Orientation |Top-left
X-Resolution |180.00000000
Y-Resolution |180.00000000
Resolution Unit |Inch
Date and Time |2001:10:22 10:00:09
YCbCr Positioning |Centred
Compression |JPEG compression
X-Resolution |180.00000000
Y-Resolution |180.00000000
Resolution Unit |Inch
Exposure Time |1/800 sec.
F-Number |f/4.7
Exif Version |Exif Version 2.1
Date and Time (Origi|2001:10:22 10:00:09
Date and Time (Digit|2001:10:22 10:00:09
Components Configura|Y Cb Cr -
Compressed Bits per |2.0000000000
Shutter Speed |9.66 EV (1/806 sec.)
Aperture |4.53 EV (f/4.8)
Exposure Bias |-0.00 EV
Maximum Aperture Val|2.87 EV (f/2.7)
Subject Distance |65.5 m
Metering Mode |Pattern
Flash |Flash did not fire
Focal Length |16.2 mm
Maker Note |410 bytes undefined data
User Comment |
FlashPixVersion |FlashPix Version 1.0
Colour Space |sRGB
Pixel X Dimension |1600
Pixel Y Dimension |1200
Focal Plane X-Resolu|7766.990291
Focal Plane Y-Resolu|7741.935483
Focal Plane Resoluti|Inch
Sensing Method |One-chip colour area sensor
File Source |DSC
Interoperability Ind|R98
Interoperability Ver|0100
RelatedImageWidth |1600
RelatedImageLength |1200
--------------------+----------------------------------------------------------
EXIF data contains a thumbnail (4098 bytes).
Could you send me a (small!) crop of the image that's not working for you? Perhaps there's something strange about it.
For reference, here's how jpegload handles metadata:
- image resolution set from JFIF, if JFIF has it
- the first XMP block in APP1 is loaded and attached to the output image
- the first Exif block is read and attached to the output image
- all APP2 ICC blocks are read, concatenated, and attached
- the exif block is parsed and fields attached to the image named as "exif-tagname", for example "exif-X-Resolution"
- the value of each field is the unlocalised value converted to ascii, followed by some descriptive text in brackets, for example
- if there's an exif tag for X-Resolution, the image resolution is set from that, overriding any JFIF resolution
You can see all this if you try "header -a file.jpg", it'll show all the tags vips has read.
On save, the opposite happens. The metadata is reconstructed from the exif- fields and reattached.
from libvips.
Thanks for looking into it. I've sent you a sample of what I've seen.
from libvips.
Here are a few improvements to exif handling:
The negative numbers you are seeing for xres/yres are a minor bug in jpegsnoop. vips is setting a very large numerator/denominator values in an attempt to approximate a floating point number, and jpegsnoop is overflowing. It's using a signed int for an unsigned int rational.
Try with exiftool and you should see the correct value.
Unfortunately I've had to change the way exif names are converted to vips metadata names and this might break some other programs. This change will probably have to wait for the next version of libvips, due in a month or two.
from libvips.
Another patch, this keeps rationals as a/b. Generating a sane rational from a double is too annoying.
from libvips.
Thanks John, much appreciated.
If you are changing the Exif code maybe something else to do is to update the ExifImageWidth and ExifImageHeight so it reflects the new size after a re-sizing. Or is that something the calling application should do?
from libvips.
Here are some more patches. First, update ExifImageWidth and Height:
And allow int-valued fields to be in any format:
from libvips.
Three more patches, and it's all done: copy over ipct tag, be less fussy about data-less exif, some cleanups.
jcupitt@c3ef2be
jcupitt@65b4056
jcupitt@20ce700
from libvips.
Related Issues (20)
- dzsave `--skip-blanks` does not work for transparent background HOT 7
- vips left many tmp fd files "/tmp/vips-117-385983422.v (deleted)" HOT 1
- VipsForeignSave: jfif is not a known file format HOT 4
- 8.15.0: ARW images throw `Input file has corrupt header` HOT 3
- tiffsave ndpi color differences HOT 1
- Crash due to running Fourier Transform operations in parallel HOT 6
- `vips_text` memory leak HOT 6
- Tiled tiff with compression and Q>=90 yields incorrect colors in 8.15 HOT 1
- 8.15 core dumps when processing lots of files HOT 8
- RW2 images: `Input file contains unsupported image format` HOT 3
- Why is Dzsave not working?
- Support for Ultra HDR HOT 20
- `vips_cache()` + sequential seems to be broken in 8.15 HOT 2
- JPEG auto-rotate changes image size HOT 1
- jxlload.c build failure: JxlDecoderGetICCProfileSize HOT 3
- Saving a greyscale tiff pyramid fails to add predictor tags at lower levels HOT 8
- Vips::Error: VipsForeignLoad: "/path/to/file.pdf" is not a known file format - installed using homebrew on macOS Ventura HOT 1
- php Libvips mapim function HOT 1
- Scale JPEG with maximum file size? HOT 1
- lipvips need 1.0.5. of libwhy but installed is 1.0.4 HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libvips.