2013-04-05 84 views
0

我必须修改6000 + jpg图像的iptc元数据。不幸的是,我没有找到任何图书馆,甚至没有找到这样的例子。将ITPC元数据写入图像

你能否给我一个提示如何修改图像的元数据或指向我可以通知我自己的网站?

+0

可能重复[IPTC .NET读/写C#库](http://stackoverflow.com/questions/5597079/iptc-net-read-write -c-sharp-library) – 2013-04-05 21:49:08

+0

我已经阅读过这个问题和答案,但据我了解,代码只描述了如何读取元数据,而不是如何写入它。 – Christopher 2013-04-05 21:56:00

回答

1

快速浏览一下System.Windows.Media.Imaging命名空间,揭示了InPlaceBitmapMetadaWriter类。我认为这是你正在寻找的:

Stream pngStream = new System.IO.FileStream("smiley.png", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); 
PngBitmapDecoder pngDecoder = new PngBitmapDecoder(pngStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); 
BitmapFrame pngFrame = pngDecoder.Frames[0]; 
InPlaceBitmapMetadataWriter pngInplace = pngFrame.CreateInPlaceBitmapMetadataWriter(); 
if (pngInplace.TrySave() == true) 
{ 
    pngInplace.SetQuery("/Text/Description", "Have a nice day."); 
} 

pngStream.Close(); 
+0

明天我会看看它。谢谢! – Christopher 2013-04-05 22:17:06