EXIF data lost on save
Posted: 2017-12-13T13:08:24-07:00
When saving a TIFF, it seems EXIF data is being scrubbed. Is there a way to prevent this? I've come across some discussions about this with the command line tools that suggested using the "-define exif-properties=true" option, but haven't had any luck with it or the Magick.NET equivalent. It is reading the EXIF data just fine from a source TIFF, and I can query EXIF values via MagickImage.GetAttribute(), but after saving to a new file those tags are gone.
Magick.NET:
Commandline:
Any ideas? Or should I post this in a general forum and figure out the commandline first?
Magick.NET:
Code: Select all
public void Save(string fileName)
{
_ImagePixels.SetPixels(_ImageBytes);
var defines = new WriteDefines { Format = _Image.Format };
defines.Defines.Add(new Define
{
Format = _Image.Format,
Name = "exif-properties",
Value = "true"
});
_Image.Write(fileName, defines);
}
class WriteDefines : IWriteDefines
{
public MagickFormat Format { get; set; }
public List<Define> Defines { get; set; } = new List<Define>();
IEnumerable<IDefine> IDefines.Defines => Defines;
}
class Define : IDefine
{
public MagickFormat Format { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
Code: Select all
magick identify -verbose sample.tif
--snip--
Properties:
aux:FlashCompensation: 0/1
aux:ImageNumber: 596
aux:Lens: AF-S DX VR Zoom-Nikkor 18-105mm f/3.5-5.6G ED
aux:LensID: 742170638
aux:SerialNumber: 3182247
date:create: 2017-12-08T14:30:40-08:00
date:modify: 2017-12-08T22:27:24-08:00
dc:format: image/tiff
exif:ApertureValue: 6.33985
exif:CompressedBitsPerPixel: 2
exif:Contrast: 0
exif:CustomRendered: 0
exif:DateTimeDigitized: 2008:08:03 08:03:00
exif:DateTimeOriginal: 2008:08:03 08:03:00
exif:DigitalZoomRatio: 1
exif:ExposureBiasValue: 0
exif:ExposureMode: 0
exif:ExposureProgram: 0
exif:ExposureTime: 0.008
exif:Flash: 24
exif:FNumber: 9
exif:FocalLength: 18
exif:FocalLengthIn35mmFilm: 27
exif:ISOSpeedRatings: 400
exif:LightSource: 0
exif:MaxApertureValue: 3.6
exif:MeteringMode: 5
--snip--
magick convert -define tiff:exif-properties=true sample.tif -negate out.tif
magick identify -verbose out.tif
--snip--
Properties:
aux:FlashCompensation: 0/1
aux:ImageNumber: 596
aux:Lens: AF-S DX VR Zoom-Nikkor 18-105mm f/3.5-5.6G ED
aux:LensID: 742170638
aux:SerialNumber: 3182247
date:create: 2017-12-13T11:21:11-08:00
date:modify: 2017-12-13T11:53:08-08:00
dc:format: image/tiff
photoshop:ColorMode: 9
photoshop:DateCreated: 2008-08-03T08:03
photoshop:ICCProfile: Camera RGB Profile
signature: be79f573c87bee6f7bf40dd3da4e99ebe971eaa79d8ceed9fe4a9df415e6f462
tiff:alpha: unspecified
tiff:endian: lsb
tiff:photometric: CIELAB
tiff:rows-per-strip: 850
xmp:CreateDate: 2008-08-03T08:03
xmp:CreatorTool: Ver.1.00
xmp:MetadataDate: 2017-12-08T14:27:17-08:00
xmp:ModifyDate: 2017-12-08T14:27:17-08:00
xmpMM:DerivedFrom: EC680DD5F5A58BDC048E110F329A7B7B
xmpMM:DocumentID: adobe:docid:photoshop:9994541d-3738-4c43-bcbf-312250965360
xmpMM:InstanceID: xmp.iid:0571e015-474f-6649-9778-d10940c2bb3f
xmpMM:OriginalDocumentID: EC680DD5F5A58BDC048E110F329A7B7B
Profiles:
--snip--