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

XmpFile::put_xmp overwrites Date created property for JPG files. (Mac/Windows) #246

Open
Blonteractor opened this issue Nov 5, 2024 · 0 comments

Comments

@Blonteractor
Copy link

Blonteractor commented Nov 5, 2024

For files that have XMP embedded in the image file itself, like JPG. The XmpFile::put_xmp 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

use xmp_toolkit::{OpenFileOptions, XmpFile, XmpValue};

fn set_image_metadata(
    file_path: &str,
    label: &str,
    rating: i32,
) -> Result<(), Box<dyn std::error::Error>> {
    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.

Platform and Version

xmp_toolkit: 1.9.1
rustc: 1.82.0
Reproduced on M1 MacOS and Windows 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant