Feature #1074
ICC Profile in APP2 segment.
100%
Description
See thread on forum [[http://dev.exiv2.org/boards/3/topics/2059?r=2065#message-2065]].
Currently, exiv2 cannot store an ICC profile (custom) in a way that is readable by most viewers (f.e. previewers or Adobe). They want the ICC profile to be in the APP2 segment. As a feature, i would like to see this possibility in exiv2. To my opinion, exiv2 would be the perfect c++ metadata/xmp/iptc/exif page in zie world.
Maybe nice to pursue for 0.27?
Files
Related issues
Associated revisions
#1074 -pC now works on tiff files. Added test convenience targets to Makefile
#1074 test files
#1074. Thanks to Max for reporting this and providing the test file.
#1074 Added Max's file to the test suite.
#1074 Fixed 'overwrite?' prompt in command: exiv2 -eC image
#1074. jpgimage.cpp ICC support (Work in Progress)
#1074 Work in progress for ICC/jpg - changes to readMetadata() and printStructure()
#1074 ICC support in jpgimage.cpp. Add test/icc-test.sh
#1074 Omitted from previous commit.
#1074 Added ICC support to tiffimage.writeMetadata(). pngimage.readMetadata() is not complete.
#1074 Work in progress. ICC Jpeg/Png/Tiff exiv2 -eC foo.xxx writes good foo.icc profiles. icc-test.sh is broken and to be investigated.
#1074. Fix bug in jpgimage.cpp/readMetadata() concerning ICC profile
#1074 For discussion see: http://dev.exiv2.org/issues/1074#note-23
#1074 Work in progress. eC -pC -eC work for JPG/PNG/TIFF/WEBP. pngimage::doWriteMetadata() does not update iCCP chunk.
#1074 Work in progress. fixed pngimage.cpp doWriteMetadata().
#1074 Tests for webp, png, tiff and jpg
#1074 Fix bug in TiffImage printStructure() for large icc profiles.
History
Updated by Robin Mills over 6 years ago
- Category changed from not-a-bug to metadata
- Priority changed from Low to Normal
Thanks, Tim. I think Exiv2 is already the best metadata library in the world and feature would make it best++.
Can we clarify the scope of this. Remember, the more you want, the less likely you are to get it AND the longer it will take!
- Read AND Write ICC Profiles?
- Most formats: JPEG, TIFF, PNG (raw, dng etc)?
- Can XMP sidecars deal with color profiles?
- Do you want to treat a Profile as a metadata container?
I've set the target to v0.26 because the other choice is 1.0. This is unlikely to be ready for v0.26 due to contention with existing commitments.
Updated by Tim Zaman over 6 years ago
Reading the APP2 profile data is usually not necessary, as it is often also, duplicated, (in my experience) in the normal section. Formats, most common where one would use this, TIFF and JPG. If you really care about color you often use JPG and TIFF.
So writing for JPEG/TIFF would be a good start. I think profile could indeed be seen as a separate container im, should be straightforward without many bells and whistles. In my experience you can almost copy the .icc file to the header verbatim.
Updated by Robin Mills over 6 years ago
Tim
To keep this simple, I'd like to limit this to JPEG, TIFF and PNG:
1) Extract ICC profile
add the option -eC extract color profile. So foo.jpg -> foo.icc
add the option -pC to write the color profile to stdout
I think the code that handles -pS (print Structure) and -pX (print XMP) can do this will minor modification
2) Replace/embed the profile:
add the option -iC import color profile. So foo.icc -> foo.{tiff|jpg|png}
I'm not offering to delve inside the data of the profile. There is all manner of color magic (LUTs and what not), however I am only offering treat the profile as a blob of binary data.
Updated by Tim Zaman over 6 years ago
Yeah making color profiles is as much art as it is science. In terms of options in a command line program, i was more interested in the c++ api, or is the cli derived from this?
Updated by Robin Mills over 6 years ago
I'll have to think about the API. At the moment, the interface on -pS and -pX is in image.hpp:
image.hpp: typedef enum { kpsNone, kpsBasic, kpsXMP } printStructureOption_e ;
image.hpp: virtual void printStructure(std::ostream& out,printStructureOption_e option=kpsNone);So you open the image and call printStructure with an option. printStructureOption_e can easily extended with kpsProfile.
I'll have to think about the API to embed/replacing an object in the image.
Updated by Robin Mills about 6 years ago
- File Reagan.jpg Reagan.jpg added
- Status changed from New to Assigned
- Assignee set to Robin Mills
- % Done changed from 0 to 30
- Estimated time set to 20.00 h
I'm going to implement the following for jpeg/png/tiff files. Of course, only jpeg have an APP2 block, however I'll also extract the profile from PNG and TIFF. All other file formats will throw an exception.
exiv2 -pC file # print profile to std::out
exiv2 -eC file # extract profile to file.icc
exiv2 -iC profile file # replace/add profile to an image
Regrettably the ICC sample application iccDumpProfile does not read from stdin and can't be used as a pipe.
794 rmills@rmillsmbp:~ $ exiv2 --verbose -pS http://dev.exiv2.org/attachments/download/820/Reagan.jpg
File 1/1: http://dev.exiv2.org/attachments/download/820/Reagan.jpg
STRUCTURE OF JPEG FILE: http://dev.exiv2.org/attachments/download/820/Reagan.jpg
address | marker | length | data
2 | 0xd8 SOI | 0
4 | 0xe0 APP0 | 16 | JFIF.....,.,......Exif..MM.*....
22 | 0xe1 APP1 | 5642 | Exif..MM.*......................
5666 | 0xe1 APP1 | 3672 | http://ns.adobe.com/xap/1.0/.<?x
9340 | 0xe2 APP2 | 3160 | ICC_PROFILE......HLino....mntrRG
12502 | 0xed APP13 | 13986 | Photoshop 3.0.8BIM.............
26490 | 0xee APP14 | 14 | Adobe.d@........................
26506 | 0xdb DQT | 132
26640 | 0xc0 SOF0 | 17
26659 | 0xdd DRI | 4
26665 | 0xc4 DHT | 418
27085 | 0xda SOS | 12
795 rmills@rmillsmbp:~ $ exiv2 --verbose -pC http://dev.exiv2.org/attachments/download/820/Reagan.jpg > Reagan.iccProfile
796 rmills@rmillsmbp:~ $ exiv2 --verbose -eC http://dev.exiv2.org/attachments/download/820/Reagan.jpg
File 1/1: http://dev.exiv2.org/attachments/download/820/Reagan.jpg
Writing iccProfile: Reagan.icc
797 rmills@rmillsmbp:~ $ ls -alt Reag*
-rw-r--r-- 1 rmills staff 9 26 Aug 17:40 Reagan.exv
-rw-r--r-- 1 rmills staff 3144 26 Aug 17:40 Reagan.icc
-rw-r--r-- 1 rmills staff 3211 26 Aug 17:40 Reagan.iccProfile
798 rmills@rmillsmbp:~ $ diff Reagan.icc Reagan.iccProfile
Binary files Reagan.icc and Reagan.iccProfile differ
799 rmills@rmillsmbp:~ $ iccDumpProfile Reagan.icc
Profile: 'Reagan.icc'
Profile ID: Profile ID not calculated.
Size: 3144(0xc48) bytes
Header
------
Attributes: Reflective | Glossy
Cmm: Unknown 'Lino' = 4C696E6F
Creation Date: 2/9/1998 06:49:00
Creator: 'HP ' = 48502020
Data Color Space: RgbData
Flags EmbeddedProfileFalse | UseAnywhere
PCS Color Space: XYZData
Platform: Microsoft
Rendering Intent: Perceptual
Type: DisplayClass
Version: 2.10
Illuminant: X=0.9642, Y=1.0000, Z=0.8249
Profile Tags
------------
Tag ID Offset Size
---- ------ ------ ----
copyrightTag 'cprt' 336 51
profileDescriptionTag 'desc' 388 108
mediaWhitePointTag 'wtpt' 496 20
mediaBlackPointTag 'bkpt' 516 20
redColorantTag 'rXYZ' 536 20
greenColorantTag 'gXYZ' 556 20
blueColorantTag 'bXYZ' 576 20
deviceMfgDescTag 'dmnd' 596 112
deviceModelDescTag 'dmdd' 708 136
viewingCondDescTag 'vued' 844 134
viewingConditionsTag 'view' 980 36
luminanceTag 'lumi' 1016 20
measurementTag 'meas' 1036 36
technologyTag 'tech' 1072 12
redTRCTag 'rTRC' 1084 2060
greenTRCTag 'gTRC' 1084 2060
blueTRCTag 'bTRC' 1084 2060
800 rmills@rmillsmbp:~ $
Updated by Robin Mills about 6 years ago
- File Reagan.tiff Reagan.tiff added
Adding Reagan.tiff with an embedded ICC profile.
Neither PhotoShop Elements nor Apple/Preview appear to be able to embed ICC profiles in PNG files.
Updated by Tim Zaman about 6 years ago
Redmine is not the place for compliments, but: awesome! <3 Robin.
Updated by Robin Mills almost 6 years ago
- % Done changed from 30 to 50
r4165 I've done more work on option -pC for PNG files. The location of the profile is documented here: http://www.w3.org/TR/PNG/#11iCCP I've can easily find the profile - however zlib refuses to decompress it! How odd. The code is submitted.
I've put in effort on -pR (recursive dump), so I now have the code available to locate profiles which are embedded in tiff-encoded records which can appear in tiff files, Exif datablocks, ExifTag records, or tiff-encoded MakerNotes.
Exiv2 man page updated to include -pC (print ICC profile to stdout) and -eC (extract ICC profile to file.icc)
Updated by Robin Mills almost 6 years ago
State of play:
Done:
-pC extract the ICC profile from png, tiff and jpeg
TODO to complete ICC Profile support for v0.26:
1 Extract ICC profile to .exv file (-eC) (Import is done, as a .exv file is a JPEG)
2 Extract ICC profile from foo.jpg to foo.icc (-ec)
3 Import ICC profile -iC
4 Update metacopy (and other samples) to respect ICC profiles
There is a related issue #1057 to add tgt modifier - for stdin/stdout to -etgt and -itgt. This will enable a useful work flow to pipe an ICC profile from one image to another:
$ exiv2 -eC- foo.tiff | exiv2 -iC- foo.jpg foo.png
Updated by Max Pozdeev over 5 years ago
Hi Robin,
I found an png image where icc profile is not displayed by exiv2. Image was produced by Apple Image Capture from scanner in grayscale.
Here the structure. Seems the profile is present.
STRUCTURE OF PNG FILE: /Pictures/scan.png
address | index | chunk_type | length | data
8 | 0 | IHDR | 13 | ............
33 | 1 | iCCP | 3294 | ICC Profile..X..W.XS...[...z..:.
3339 | 2 | pHYs | 9 | .........
3360 | 3 | iTXt | 596 | XML:com.adobe.xmp.....<x:xmpmeta
3968 | 4 | IDAT | 16384 | x.....%Y.......UY.==.0.p...w..".
20364 | 5 | IDAT | 14548 | y.oCU`......C7.....9.1N#......1
34924 | 6 | IEND | 0 |
Updated by Robin Mills over 5 years ago
Ah, that's very helpful. I'll have a look at that. Thanks for letting me know.
Updated by Robin Mills over 5 years ago
Fixed. Good find, Max. Fix submitted r4229
I've modified the code to do case-independant check on the "ICC...".
$ exiv2 -pR ~/Downloads/scan.png
STRUCTURE OF PNG FILE: /Users/rmills/Downloads/scan.png
address | index | chunk_type | length | data
8 | 0 | IHDR | 13 | ............
33 | 1 | iCCP | 3294 | ICC Profile..X..W.XS...[...z..:.
3339 | 2 | pHYs | 9 | .........
3360 | 3 | iTXt | 596 | XML:com.adobe.xmp.....<x:xmpmeta
3968 | 4 | IDAT | 16384 | x.....%Y.......UY.==.0.p...w..".
20364 | 5 | IDAT | 14548 | y.oCU`......C7.....9.1N#......1
34924 | 6 | IEND | 0 |
$ exiv2 -pC ~/Downloads/scan.png > /tmp/scan.icc ; ls -alt /tmp/scan.icc
-rw-r--r-- 1 rmills wheel 6562 17 Mar 22:29 /tmp/scan.icc
$ iccDumpProfile /tmp/scan.icc
Profile: '/tmp/scan.icc'
Profile ID: Profile ID not calculated.
Size: 4456(0x1168) bytes
Header
------
Attributes: Reflective | Glossy
Cmm: Apple
Creation Date: 8/23/2012 15:46:15
Creator: 'appl' = 6170706C
Data Color Space: GrayData
Flags EmbeddedProfileFalse | UseAnywhere
PCS Color Space: XYZData
Platform: Macintosh
Rendering Intent: Perceptual
Type: DisplayClass
Version: 2.00
Illuminant: X=0.9642, Y=1.0000, Z=0.8249
Profile Tags
------------
Tag ID Offset Size
---- ------ ------ ----
profileDescriptionTag 'desc' 192 121
Unknown 'dscm' = 6473636D 'dscm' 316 2024
copyrightTag 'cprt' 2340 35
mediaWhitePointTag 'wtpt' 2376 20
grayTRCTag 'kTRC' 2396 2060
$Updated by Robin Mills over 5 years ago
I've updated the test suite to include Max's file. r4230. I assume you are happy to donate your file, please say otherwise.
Updated by Max Pozdeev over 5 years ago
Robin, thank you for the patch. The file was made specially for tests, use as you wish.
Updated by Robin Mills about 5 years ago
- % Done changed from 70 to 80
Mostly done. I'll have to test this, update the test suite appropriately and fix things that have still to be implemented.
Updated by Robin Mills about 5 years ago
- % Done changed from 80 to 60
- Estimated time changed from 20.00 h to 60.00 h
Updated by Robin Mills about 5 years ago
- % Done changed from 60 to 70
- Estimated time changed from 60.00 h to 40.00 h
Updated by Robin Mills about 5 years ago
- % Done changed from 80 to 90
r4479 Fix submitted for tiffImage::doWriteMetadata().
image::findIccProfile() is closed the FILE* when called from pngImage::readMetadata().
Updated by Robin Mills about 5 years ago
- % Done changed from 90 to 80
- Estimated time changed from 40.00 h to 50.00 h
r4492 Many fixes.
Thanks to Phil for some advice about the jpeg/embedding. http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,7586.0.html
And Thanks to Ben for using GIMP to to create test/data/ReaganLargeXxx.xxx files.
Stuff remaining:
1) $ exiv2 -iC foo.png (in pngimage.cpp/doWriteMetadata())
2) tests for tiff/jpeg/png/webp in test/icc-test.sh
3) $ exiv2 -iC- to read profile from stdin is doubtful
4) $ exiv2 -eC- to write profile to stdout is doubtful
Updated by Robin Mills about 5 years ago
- % Done changed from 80 to 90
r4495 Fix writing PNG files. Into the end game. More testing and this will be finished.
Updated by Robin Mills about 5 years ago
- Status changed from Assigned to Closed
- % Done changed from 90 to 100
r4499 Tests for JPG/WEBP/TIFF/PNG
#1074. Implemented exiv2 options -eC and -pC for JPEG.