Magick.NET icon indicating copy to clipboard operation
Magick.NET copied to clipboard

AddThumbnail(byte[] data) to ExifProfile

Open gerwintmg opened this issue 5 years ago • 3 comments

Is your feature request related to a problem? Please describe

I'm using Magick.net to update Exif metadata, but could not find a way, to replace the thumbnail image.

Describe the solution you'd like

I would like to be able to replace the thumbnail, by using magick.net

Describe alternatives you've considered

I have tried to make an extension method but did not find a way to add the thumbnail image data.

ImageMagick.ExifProfile exifProfile = image.GetExifProfile();
exifProfile = (null == exifProfile) ? new ImageMagick.ExifProfile() : exifProfile;
exifProfile.RemoveThumbnail();

exifProfile.SetValue(ExifTag.JPEGInterchangeFormat, ""); // ThumbnailOffset 
exifProfile.SetValue(ExifTag.JPEGInterchangeFormatLength, ""); // ThumbnailLength

gerwintmg avatar Apr 08 '20 11:04 gerwintmg

At this moment there is no support for adding thumbnails. The code that creates the byte array that is passed to ImageMagick does not write the thumbnail at the moment. It might be possible but I will need to investigate that.

dlemstra avatar Apr 11 '20 15:04 dlemstra

If I were to look into adding this as a feature (since I need it myself), what would be a good place to start looking?

Kjelldor avatar Mar 24 '23 13:03 Kjelldor

Thanks for offering to help me with this @Kjelldor. To add this functionality changes need to be made to the following classes:

ExifProfile => A new method should be added that can be used to add the thumbnail to the profile. The input argument should probably be an (IMagickImage) that is then converted to a byte array with MagickFormat.Jpeg that is probably stored on the ExifData. ExifWriter => This should be changed to add the thumbnail directory and data to the end of the profile. This will probably require changing some internal arguments. This is probably the most difficult part and I would advise you to check the exif specs to see how that should be added.

Feel free to reach out if you need more help.

dlemstra avatar Mar 25 '23 07:03 dlemstra