ImageSharp icon indicating copy to clipboard operation
ImageSharp copied to clipboard

Support for XMP metadata

Open mbaumanndev opened this issue 6 years ago • 19 comments

As discussed on Gitter, ImageSharp doesn't support XMP at the moment, it would be interesting to have support for it

mbaumanndev avatar Mar 22 '19 08:03 mbaumanndev

If anyone wants to take this on specification information can be found here.

https://www.adobe.com/devnet/xmp.html

JimBobSquarePants avatar Mar 27 '19 11:03 JimBobSquarePants

@JimBobSquarePants I'm interested in implementing support for XMP metadata. I think the feature is useful. Please assign the task to me.

IldarKhayrutdinov avatar Aug 06 '19 16:08 IldarKhayrutdinov

Hey, @IldarKhayrutdinov thanks for your interest! Feel free to pick up, and feel free to discuss the topic and ask any question either here or on gitter.

antonfirsov avatar Aug 06 '19 21:08 antonfirsov

@antonfirsov thanks! Yes, I will need to discuss API.

IldarKhayrutdinov avatar Aug 07 '19 06:08 IldarKhayrutdinov

@antonfirsov Пардон, вы по русски не говорите?)

IldarKhayrutdinov avatar Aug 08 '19 13:08 IldarKhayrutdinov

Говорю, ну я с детства в Венгрии живу, поэтому девелоперский диалект совсем пропустил. Последнее времья стараюсь его в Ютубе изучать. Заговорить на нём мне пока не просто ))

Ну я не обойдусь, скоро в Прагу переселяюсь, много русских коллег будут.

antonfirsov avatar Aug 08 '19 22:08 antonfirsov

@antonfirsov Я очень рад) Пишете, по крайней мере, очень грамотно, а у меня с английским не так хорошо, как хотелось бы... Тут можно по русски обсуждать вопросы проекта?

IldarKhayrutdinov avatar Aug 09 '19 07:08 IldarKhayrutdinov

А можем в гиттере? Там просто более просше обсуждать код, чем в майле, и не будем спамить других сдесь.

ПМ меня - есле ОК. Есле нет, напишу майл.

antonfirsov avatar Aug 10 '19 00:08 antonfirsov

Ага, гиттер удобнее, написал там.

IldarKhayrutdinov avatar Aug 10 '19 08:08 IldarKhayrutdinov

I haven't enough time :( enjoy who want to take this task!

IldarKhayrutdinov avatar Sep 05 '19 16:09 IldarKhayrutdinov

@dlemstra You've touched on this before haven't you. Do you have any info you can share that someone can start with?

JimBobSquarePants avatar Sep 06 '19 00:09 JimBobSquarePants

My Magick.NET project contains a very simple XMP profile class (https://github.com/dlemstra/Magick.NET/blob/master/src/Magick.NET/Shared/Profiles/XmpProfile.cs). This just a very simple wrapper to make it easier to access to xml. And to detect it you will need to check the JPEG metadata similar to the exif profile and check if it starts with http://ns.adobe.com/xap/1.0/ .

dlemstra avatar Sep 06 '19 05:09 dlemstra

Interesting thanks! I'll have to have a look at the spec to see what else we'd need to do to add more user friendly editing

JimBobSquarePants avatar Sep 06 '19 07:09 JimBobSquarePants

@JimBobSquarePants I recently spent a lot of time implementing XMP support for Paint.NET earlier this year. Happy to consult and provide sample code. This stuff is a beast, it took me a full month to get it all figured out, coded, and refined. You can also reflector/ilspy/dnSpy over the app's binaries. Look for XmpPacket in PDN.Core.dll as a starting point.

rickbrew avatar Oct 12 '20 15:10 rickbrew

First step of XMP support is, I guess, is to load and store XMP packets as raw XML. According to the XMP Specifications, the metadata can be embedded in the following image types:

  • GIF
  • JPEG
  • PNG
  • TIFF
  • WebP (Part of #1802 )

I'm willing to take up the work of exposing this in a proper Profile class and connecting that up to the Encoders and Decoders. As a first step, just with the content of the XMP packets as XML. That means at least ImageSharp will have some level of support for XMP. I think this aligns with the level that Magick.NET offers, but doesn't reach what Paint.NET can do.

To reach the level of user friendly editing is more design work though. Not sure I'm up for that.

Do you guys agree the basic level of support adds value already?

ynse01 avatar Dec 20 '21 21:12 ynse01

In Paint.NET, I only bubble up XMP as the raw XML. If a plugin wants to handle XMP they have to parse the XML themselves. The main -- frankly only -- goal of adding XMP support to the app was to preserve it across file open/save actions. Creating an object model against XMP is IMO not worth the effort unless you find strong need for it.

The really hard part of XMP support was reading and writing it from the EXIF chunks in JPEG files. It was pretty tricky, and you need to have a bunch of sample images to work with, especially ones that have a large amount of XMP data (>64K, IIRC), which has to be encoded across multiple chunks.

Here's one such example image, which contains megabytes of ridiculous Photoshop history data encoded into the XMP: BLOATED_1580380752x15221my1003glhdp1001t3extyellowrear.zip If you can preserve that across open/save, you are making great progress.

rickbrew avatar Dec 21 '21 03:12 rickbrew

Personally, I would be fine exposing the raw XML in some read-only form (maybe as string). We don't want to make it editable if we cannot validate the contents.

BTW isn't there an XSD schema for the whole thing? That would enable to auto-generate the classes and ship them in an external experimental library.

antonfirsov avatar Dec 21 '21 12:12 antonfirsov

There's actually projects out there that can handle the data. https://github.com/drewnoakes/xmp-core-dotnet

JimBobSquarePants avatar Jan 03 '22 14:01 JimBobSquarePants

I'm reopening this as I'd like to, at some point, add full read/write capability.

JimBobSquarePants avatar Jan 11 '22 01:01 JimBobSquarePants