Writing the xmp to file changes the Creation date of the file
- Dominant language
- C++
- Stars
- 262
- Forks
- 110
- PR merge metrics
- No merged PRs in 30d
Description
For files that have XMP embedded in the image file itself, like JPG. The `PutXmp` function is overwriting the `Date Created` property of that file. What's even weirder is it only changes it the first time I copy the photos from an IPhone that clicked the photos to my laptop. On subsequent runs only the `Date Modified` is changed, which is expected.
### Expected Behaviour
Only the `Date Modified` should change and the `Date Created` should not be affected.
### Actual Behaviour
`Date Created` is changed on the first run.
#### Steps to Reproduce
This is the equivalent code using the rust bindings. (I am not sure about the C++ code, but this just calls the C++ functions under the hood)
```rs
use xmp_toolkit::{OpenFileOptions, XmpFile, XmpValue};
fn set_image_metadata(
file_path: &str,
label: &str,
rating: i32,
) -> Result<(), Box> {
let mut file = XmpFile::new().unwrap();
file.open_file(file_path, OpenFileOptions::default().for_update())
.unwrap();
let mut xmp_meta = file.xmp().unwrap();
xmp_meta.set_property(
"http://ns.adobe.com/xap/1.0/",
"Label",
&XmpValue::from(label),
)?;
xmp_meta.set_property(
"http://ns.adobe.com/xap/1.0/",
"Rating",
&XmpValue::from(rating.to_string()),
)?;
file.put_xmp(&xmp_meta).unwrap();
file.try_close().unwrap();
Ok(())
}
fn main() {
let file_path = "";
set_image_metadata(file_path, "Red", 1).unwrap();
}
```
1. Click a JPG photo from your phone.
2. Copy the photo over your PC.
3. Run the above code on your photo.
4. Watch the `Creation Time` change from when you clicked the photo to the time you ran the code.
5. On subsequent runs of the same code, the `Creation Time` is not changed anymore, it stays on the time you first ran the code.
Contributor guide
Research direction
Start at the C++ PutXmp implementation and the Rust binding's put_xmp path used in the reproduction. Compare the first and subsequent writes while checking the file's Creation Time and Date Modified; done means metadata changes preserve Creation Time while updating only Date Modified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100