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

Metadata not copied from Camera RAW source image to JPEG output #60

Open
marnilss opened this issue Dec 15, 2020 · 2 comments
Open

Metadata not copied from Camera RAW source image to JPEG output #60

marnilss opened this issue Dec 15, 2020 · 2 comments

Comments

@marnilss
Copy link

Hi,
Just found your nuget package and am trying to generate thumbnails of my Sony ARW (RAW) photos.
The thumbnail stuff is working great, but I would also like to copy some of the metadata to the resulting JPEG file.
I've tried with

var settings = new ProcessImageSettings
{
    Width = 300,
    Height = 300,
    DpiX = 96,
    DpiY = 96,
    SaveFormat = FileFormat.Jpeg,
    ResizeMode = CropScaleMode.Contain,
    JpegQuality = 60,
    MetadataNames = new[] { "System.Comment",
                            "System.Keywords",
                            "System.Rating",
                            "System.Subject",
                            "System.Title",
                            "System.Photo.CameraManufacturer",
                            "System.Photo.CameraModel",
                            "System.Photo.DateTaken" }
};

And the output file never gets any of the metadata I know is in the ARW file (file properties in Explorer is able to display them).

Running Windows 10 1909

Thanks in advance

Marcus Nilsson

@marnilss
Copy link
Author

Here is a zipped ARW file you can test with.
DSC00002.zip

@saucecontrol
Copy link
Owner

saucecontrol commented Dec 15, 2020

Hey Marcus, thanks for the detailed repro. It appears this is a limitation of the way Windows Photo Metadata Policies are defined per-codec. I can see that at least some of the requested metadata is present in your sample image, which uses a basic TIFF metadata layout.

Unfortunately, it seems the paths defined by a given policy apply only to the codecs explicitly listed in that policy. For example, System.Photo.CameraManufacturer lists a TIFF path of /ifd/{ushort=271}, and while the data is present in your raw file under that path, it is not retrieved when using the policy name. I assume this is because the camera raw codec doesn't subscribe to that policy. The values can, however, be retrieved by the explicit path. For example, the following values are all present:

MetadataNames = new[] {
    "/ifd/{ushort=271}",       // camera make
    "/ifd/{ushort=272}",       // camera model
    "/ifd/exif/{ushort=36867}" // date taken
}

The second issue is that when using explicit paths to reference metadata items, the path must be valid in both the source and destination formats. The above example paths work when saving to TIFF output since the paths are valid for both the camera raw and TIFF containers, but when saving to JPEG, the paths above must be prefixed with /app1 to be valid. For the most part, the Photo Metadata Policies obscure these differences, but of course that only works when both formats have the policy defined.

I am currently in the process of reworking MagicScaler to support codecs other than those shipping in Windows, and redefining metadata reading and writing is part of that. In the meantime, I can only suggest using another tool (like exiftool) to post-process your thumbnails if you need the metadata preserved.

@saucecontrol saucecontrol changed the title Can't get any metadata copied to output file Metadata not copied from Camera RAW source image to JPEG output Dec 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants