Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copyright Flag field #2054

Closed
viskin opened this issue Jan 11, 2022 · 9 comments
Closed

Copyright Flag field #2054

viskin opened this issue Jan 11, 2022 · 9 comments
Labels
support Anything related to a user needing help with exiv2

Comments

@viskin
Copy link

viskin commented Jan 11, 2022

We want to be able to read / preserve the field "Copyright Flag" that Photoshop adds to metadata.
It's different from Exif.Image.Copyright, and documented here
It appears that having this field preserved when copying / modifying metadata is important for professional photographers.

Does exiv2 have support for this field?

If not, is it possible to add this field to supported by Exiv2?

If not possible to have it to supported filed, at least can it be kept when exporting metadata? Currently it just removed. I can provide such jpeg file if needed.

@viskin viskin added the request feature request or any other kind of wish label Jan 11, 2022
@clanmills
Copy link
Collaborator

@vishkin Thanks for bringing up this topic. Exiv2 supports Exif, IPTC, Xmp and embedded ICC profiles. The metadata you are discussing is private to PhotoShop. To my knowledge there is no code in Exiv2 to read/write/delete PhotoShop metadata.

In general, Exiv2 tries to do no harm, so the data should be preserved when Exiv2 updates a file.

I don't have a copy of PhotoShop. If you have PhotoShop, perhaps you can run some tests to see if any damage is being done.

I discuss the PhotoShop PSD file format in my book https://www.exiv2.org/book/index.html#PSD. The tvisitor.cpp code that accompanies my book dumps PhotoShop files. I don't have a PSD file that uses record 0x040A, although I believe the tvisitor program will reveal the data when present.

571 rmills@rmillsmm-local:~/gnu/github/exiv2/0.27-maintenance $ tvisitor -pRU test/data/exiv2-photoshop.psd 
STRUCTURE OF PSD FILE (MM): test/data/exiv2-photoshop.psd
 address | length | data
      26 |      0 | 
      30 |  23142 | 8BIM.._____...Z_..%G..__.___8BIM.%_____.
  STRUCTURE OF 8BIM FILE (MM): test/data/exiv2-photoshop.psd:34->23142
       offset |   kind | tagName                              |  len | data | 
            0 | 0x0404 | PSD.8BIM.IPTCNAA                 |   15 | 12+1 | ..Z____________
    STRUCTURE OF IPTC FILE (MM): test/data/exiv2-photoshop.psd:34->23142:12->15
        Record | DataSet | Name                           | Length | Data
             1 |      90 | Iptc.Envelope.CharacterSet     |      3 | .%G
             2 |       0 | Iptc.Application.RecordVersion |      2 | __
    END: test/data/exiv2-photoshop.psd:34->23142:12->15
           28 | 0x0425 | PSD.8BIM.0x425                   |   16 | 12+0 | ...}____________
           56 | 0x0424 | PSD.8BIM.XMP                     |   30 | 12+0 | <?xpacket begin="..." id="W5M0
        15628 | 0x043a | PSD.8BIM.0x43a                   |   30 | 12+1 | ___.___._____.printOutput___._
        15882 | 0x043b | PSD.8BIM.0x43b                   |   30 | 12+0 | ___.___._____.printOutputOptio
        16328 | 0x03ed | PSD.8BIM.0x3ed                   |   16 | 12+0 | _H______________
        16356 | 0x0426 | PSD.8BIM.0x426                   |   14 | 12+0 | ______________
        16458 | 0x03f5 | PSD.8BIM.0x3f5                   |   30 | 12+0 | _/ff_._lff_._____._/ff_._..._.
        16542 | 0x03f8 | PSD.8BIM.0x3f8                   |   30 | 12+0 | __........................____
        16666 | 0x0408 | PSD.8BIM.0x408                   |   16 | 12+0 | ___.____________
        16710 | 0x041a | PSD.8BIM.0x41a                   |   30 | 12+1 | ___.___________[___.___._e_x_i
        17566 | 0x0428 | PSD.8BIM.0x428                   |   12 | 12+0 | ____________
        17620 | 0x040c | PSD.8BIM.Thumbnail               |   30 | 12+1 | ___.___.___[__..__..__.=_._...
        22330 | 0x0421 | PSD.8BIM.Version                 |   30 | 12+1 | ___..___._A_d_o_b_e_ _P_h_o_t_
        22428 | 0x0422 | PSD.8BIM.Exif                    |   30 | 12+0 | MM_*___._..__.___._.__.._.___.
        22822 | 0x0fa0 | PSD.8BIM.0xfa0                   |   30 | 12+0 | maniIRFR__._8BIMAnDs___.___.__
        23102 | 0x0fa1 | PSD.8BIM.0xfa1                   |   28 | 12+0 | mfri___.___.___.____________
  END: test/data/exiv2-photoshop.psd:34->23142
   23176 |     32 | ________8BIMFMsk___.__.._______2
END: test/data/exiv2-photoshop.psd
572 rmills@rmillsmm-local:~/gnu/github/exiv2/0.27-maintenance $ 

@clanmills clanmills added support Anything related to a user needing help with exiv2 and removed request feature request or any other kind of wish support Anything related to a user needing help with exiv2 labels Jan 11, 2022
@viskin
Copy link
Author

viskin commented Jan 11, 2022

I'm talking about metadata that Photoshop stores in jpg, not psd files.
When doing exiv2 ex image.jpg, the resulting .exv file will have this field removed. That's exactly the problem that the field not being preserved.
I will attach repro with jpeg file soon.

@viskin
Copy link
Author

viskin commented Jan 11, 2022

The repro image is attached.

exiv2 -e X ex .\copyright-flag.jpg

The original jpeg has Copyright Flag = true.
Neither resulting .exv nor .xmp files preserve it.
I check it with exiftool:

exiftool -s -CopyrightFlag .\copyright-flag.jpg
# CopyrightFlag                   : True
exiftool -s -CopyrightFlag .\copyright-flag.exv
# No tag
exiftool -s -CopyrightFlag .\copyright-flag.xmp
# No tag

Of course, copying metadata from one image to another also loses the tag.

copyright-flag

@clanmills
Copy link
Collaborator

Thank you for providing a test image. That's very helpful.

You have extracted the EXV and XMP files from the the JPEG. They do not contain the PhotoShop/8BIM Copyright record for two reasons:

  1. Exiv2 does not support PhotoShop/8BIM metadata.
  2. The extracted .exv and .xmp files are copies of the Exif and Xmp metadata. As PhotoShop/8BIM is neither Exif nor Xmp metadata, it would not be copied to those files _even if exiv2 supported PhotoShop/8BIM metadata.

I have reproduced your exiftool output:

589 rmills@rmillsmm-local:~/clanmills $ exiftool -s -CopyrightFlag ~/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg 
CopyrightFlag                   : True
590 rmills@rmillsmm-local:~/clanmills $ 

I have investigated the storage of Copyright in your file as follows:

$ exiftool -v5 -s -CopyrightFlag ~/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg
....
  + [Photoshop directory, 13036 bytes]
  | ResolutionInfo (SubDirectory) -->
  | - Tag 0x03ed (16 bytes):
  |     338d: 00 f0 00 00 00 01 00 01 00 f0 00 00 00 01 00 01 [................]
  | + [BinaryData directory, 16 bytes]
  | | XResolution = 15728640
  | | - Tag 0x0000 (4 bytes, int32u[1]):
  | |     338d: 00 f0 00 00                                     [....]
  | | DisplayedUnitsX = 1
  | | - Tag 0x0002 (2 bytes, int16u[1]):
  | |     3391: 00 01                                           [..]
  | | YResolution = 15728640
  | | - Tag 0x0004 (4 bytes, int32u[1]):
  | |     3395: 00 f0 00 00                                     [....]
  | | DisplayedUnitsY = 1
  | | - Tag 0x0006 (2 bytes, int16u[1]):
  | |     3399: 00 01                                           [..]
  | CopyrightFlag = .
  | - Tag 0x040a (1 bytes):
  |     33a9: 01
 ...

The 0x040a Record is a field of the 0x03ed record (of 16 bytes) which tvisitor correct find (and does not decode).

588 rmills@rmillsmm-local:~/clanmills $ tvisitor -pRU ~/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg 
STRUCTURE OF JPEG FILE (II): /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg
 address | marker       |  length | signature
       0 | 0xffd8 SOI  
       2 | 0xffe1 APP1  |   13163 | Exif__II*_.___._..._.___>___..._.___F___
  STRUCTURE OF TIFF FILE (II): /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg:12->13155
...
  END: /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg:12->13155
   13167 | 0xffed APP13 |   13052 | Photoshop 3.0_8BIM.._____._.___._._.___.
  STRUCTURE OF 8BIM FILE (MM): /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg:13185->13034
       offset |   kind | tagName                              |  len | data | 
            0 | 0x03ed | PSD.8BIM.0x3ed                   |   16 | 12+0 | _.______________           <---------- It's in here
           42 | 0x040c | PSD.8BIM.Thumbnail               |   30 | 12+1 | ___.__.____.__.__.@___2._._...
  END: /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg:13185->13034
   26221 | 0xffe2 APP2  |    3160 | ICC_PROFILE_..__.HLino..__mntrRGB XYZ ..
   29383 | 0xffe1 APP1  |     780 | http://ns.adobe.com/xap/1.0/_<?xpacket b
...
   30544 | 0xffda SOS  
  965233 | 0xffd9 EOI  
END: /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg
589 rmills@rmillsmm-local:~/clanmills $ 

I would like to close this issue as "out of scope" for two reasons:

  1. Exiv2 does not support PhotoShop/8BIM metadata.
  2. The .exv and .xmp files are correct. They are Exif and XMP metadata and do not copy the PhotoShop/8BIM metadata.

You may wish to open an enhancement request "Provide support for PhotoShop/8BIM metadata". Based on the work-load on the team at present, your request is unlikely to be prioritised for implementation. I've been working with Exiv2 for 14 years and this might be the first time that PhotoShop/8BIM has been discussed. However a team member is currently investigating a request to support PNG/textual information #147 and your request might dovetail with that effort.

Please understand however that PhotoShop/8BIM metadata cannot be stored in .exv and/or .xmp files. The Exif tag Exif.Image.Copyright is supported in .exv.

@clanmills
Copy link
Collaborator

There's a bug in tvisitor.cpp and it skips the 0x040a (Copyright) record. I'll fix that (it's not part of the Exiv2 product).

569 rmills@rmillsmm-local:~/gnu/exiv2/team/book $ dmpf /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg start=13185 count=60 width=28
       0        0: 8BIM.._____._.___._._.___._.  ->  38 42 49 4d 03 ed 00 00 00 00 00 10 00 f0 00 00 00 01 00 01 00 f0 00 00 00 01 00 01
    0x1c       28: 8BIM.._____.._8BIM..____2.__  ->  38 42 49 4d 04 0a 00 00 00 00 00 01 01 00 38 42 49 4d 04 0c 00 00 00 00 32 b5 00 00
    0x38       56: _.__                          ->  00 01 00 00
570 rmills@rmillsmm-local:~/gnu/exiv2/team/book $ 

This should be reported as:

  STRUCTURE OF 8BIM FILE (MM): /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg:13185->13034
       offset |   kind | tagName                          |  len | data | 
            0 | 0x03ed | PSD.8BIM.0x3ed                   |   28 | 12+0 | _.___._._.___._.____________
           28 | 0x040a | PSD.8BIM.0x40a                   |    1 | 12+1 | .
           42 | 0x040c | PSD.8BIM.Thumbnail               |   30 | 12+1 | ___.__.____.__.__.@___2._._...
  END: /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg:13185->13034

However, that doesn't change the substance of this issue which is the question you asked: Does exiv2 have support for this field? and the answer is no. Exiv2 does not support PhotoShop/8BIM metadata.

@clanmills clanmills added the support Anything related to a user needing help with exiv2 label Jan 11, 2022
@clanmills
Copy link
Collaborator

Fix submitted to book/tvisitor.cpp (and consequential test changes).
svn://dev.exiv2.org/svn/team/book r5368

621 rmills@rmillsmm-local:~/gnu/exiv2/team/book $ svn log tvisitor.cpp | head 
------------------------------------------------------------------------
r5368 | robinwmills | 2022-01-11 16:34:20 +0000 (Tue, 11 Jan 2022) | 1 line

Fix issue in C8BIM::accept(Visitor& visitor) and associated test consequences.  See: https://github.com/Exiv2/exiv2/issues/2054

@viskin
Copy link
Author

viskin commented Jan 11, 2022

I understand. Thanks a lot. We will try to find some means to preserve PhotoShop/8BIM separately to exv.

@clanmills
Copy link
Collaborator

clanmills commented Jan 11, 2022

The PhotoShop/8BIM data is stored in the APP13 segment in the JPEG. exiv2 reveals it with the -pS option.

659 rmills@rmillsmm-local:~/clanmills $ exiv2 -pS ~/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg 
STRUCTURE OF JPEG FILE: /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg
 address | marker       |  length | data
       0 | 0xffd8 SOI  
       2 | 0xffe1 APP1  |   13163 | Exif..II*...............>......
   13167 | 0xffed APP13 |   13052 | Photoshop 3.0.8BIM..............
   26221 | 0xffe2 APP2  |    3160 | ICC_PROFILE......HLino....mntrRG chunk 1/1
   29383 | 0xffe1 APP1  |     780 | http://ns.adobe.com/xap/1.0/.<?x
   30165 | 0xffdb DQT   |     132 
   30299 | 0xffdd DRI   |       4 
   30305 | 0xffee APP14 |      14 | Adobe.d.....
   30321 | 0xffc0 SOF0  |      17 
   30340 | 0xffc4 DHT   |     202 
   30544 | 0xffda SOS  
660 rmills@rmillsmm-local:~/clanmills $ 

You can extract it to file with the dd command. exiv2 only extracts the APP1/Exif segment when creating a .exv.

660 rmills@rmillsmm-local:~/clanmills $ exiv2 -ea --verbose ~/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg 
File 1/1: /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg
Writing Exif data from /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg to /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.exv
Writing XMP data from /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg to /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.exv
661 rmills@rmillsmm-local:~/clanmills $ tvisitor -pS ~/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.exv 
STRUCTURE OF EXV FILE (II): /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.exv
 address | marker       |  length | signature
       7 | 0xffe1 APP1  |   13164 | Exif__II*_.___._..._.___>___..._.___F___
   13173 | 0xffe1 APP1  |    2740 | http://ns.adobe.com/xap/1.0/_<?xpacket b
   15915 | 0xffd9 EOI  
END: /Users/rmills/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.exv
662 rmills@rmillsmm-local:~/clanmills $ 

You could use dd to insert the APP13 segment into the .exv file.

I don't know what you're seeking to achieve here. The exiv2 command-line option -ee extracts Exif metadata and -ea is "all metadata". The specification of the option -ea could be modified to say retain the APP13 segment when you write a .exv file.

Team Exiv2 has an expert on the options for the exiv2 command-line program. Perhaps you could explain your use case before we involve somebody else with this issue. I'm confident that a bash script can be easily created to provide this feature without modifying the C++ code in exiv2.

@clanmills
Copy link
Collaborator

I'm a little surprised not to have heard from you. Let me explain in detail how to use dd to create a .exv file that contains the 8BIM/Copyright flag.

1. Extract the 8BIM segment from the original file

745 rmills@rmillsm1:~ $ mkdir -p ~/foo
746 rmills@rmillsm1:~ $ cd ~/foo
747 rmills@rmillsm1:~/foo $ cp ~/Desktop/148954173-cec1a94b-fda4-4ef6-9e4d-b5c7ef98bd2f.jpg orig.jpg
748 rmills@rmillsm1:~/foo $ exiv2 -pS orig.jpg 
STRUCTURE OF JPEG FILE: orig.jpg
 address | marker       |  length | data
       0 | 0xffd8 SOI  
       2 | 0xffe1 APP1  |   13163 | Exif..II*...............>......
   13167 | 0xffed APP13 |   13052 | Photoshop 3.0.8BIM..............
   26221 | 0xffe2 APP2  |    3160 | ICC_PROFILE......HLino....mntrRG chunk 1/1
   29383 | 0xffe1 APP1  |     780 | http://ns.adobe.com/xap/1.0/.<?x
   30165 | 0xffdb DQT   |     132 
   30299 | 0xffdd DRI   |       4 
   30305 | 0xffee APP14 |      14 | Adobe.d.....
   30321 | 0xffc0 SOF0  |      17 
   30340 | 0xffc4 DHT   |     202 
   30544 | 0xffda SOS  
749 rmills@rmillsm1:~/foo $ dd bs=1 count=$((13052+4)) skip=$((13167-1)) if=orig.jpg of=app13 2>/dev/null 

2. Create the .exv and cut it into two

750 rmills@rmillsm1:~/foo $ exiv2 -ee orig.jpg 
751 rmills@rmillsm1:~/foo $ exiv2 -pS orig.exv 
STRUCTURE OF JPEG FILE: orig.exv
 address | marker       |  length | data
       0 | 0xff01      
       7 | 0xffe1 APP1  |   13164 | Exif..II*...............>......
   13173 | 0xffd9 EOI  
752 rmills@rmillsm1:~/foo $ dd bs=1 count=13173 if=orig.exv of=start 2>/dev/null
753 rmills@rmillsm1:~/foo $ dd bs=1 skip=13173 count=2 if=orig.exv of=eoi 2>/dev/null

3. Manufacture a new .exv

754 rmills@rmillsm1:~/foo $ cat start app13 eoi > new.exv
755 rmills@rmillsm1:~/foo $ exiv2 -pS new.exv 
STRUCTURE OF JPEG FILE: new.exv
 address | marker       |  length | data
       0 | 0xff01      
       7 | 0xffe1 APP1  |   13164 | Exif..II*...............>......
   13174 | 0xffed APP13 |   13052 | Photoshop 3.0.8BIM..............
   26229 | 0xffd9 EOI  
756 rmills@rmillsm1:~/foo $ exiftool -s -CopyrightFlag new.exv 
CopyrightFlag                   : True
757 rmills@rmillsm1:~/foo $ ls -l
total 2048
-rw-r--r--  1 rmills  staff   13056 13 Jan 04:18 app13
-rw-r--r--  1 rmills  staff       2 13 Jan 04:19 eoi
-rw-r--r--  1 rmills  staff   26231 13 Jan 04:20 new.exv
-rw-r--r--  1 rmills  staff   13175 13 Jan 04:19 orig.exv
-rw-r--r--@ 1 rmills  staff  965235 13 Jan 04:18 orig.jpg
-rw-r--r--  1 rmills  staff   13173 13 Jan 04:19 start
758 rmills@rmillsm1:~/foo $ 

Good, eh?

We will try to find some means to preserve PhotoShop/8BIM separately to exv.

Write a script to extract/modify a .exv to store the PhotoShop/8BIM data.

Is that what you want?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Anything related to a user needing help with exiv2
Projects
None yet
Development

No branches or pull requests

2 participants