Sorry I Have been away.
Anyway .net 3.5 and the code you suggested is what i have used except i
have
change it from tiff to jpeg
I have read the skimpy examples the msdn provides.
Did you try it with a jpeg?
Thanks
Roger
Hi Roger,
I tried the code given on MSDN on the following Url:
http://msdn.microsoft.com/en-us/library/aa970450.aspx
And it was running perfectly for me, so please let me know which
version
of
.NET are you using and also what is the specific error\exception that
you
have been getting.
regards,
Joy
:
Code I have used so far
This is the class i have for reding the data which works fine
<snip>
using System.Windows.Media.Imaging;
using System.IO;
<snip>
/// <summary>
/// Returns Image MetaData Preformated in a table
/// using System.Windows.Media.Imaging (ref)
/// dot.net 3.5 standard
///
/// </summary>
public static string returnMetaData(string imgFile)
{
string MetaData = null;
BitmapSource img = BitmapFrame.Create(new Uri(imgFile));
BitmapMetadata meta = (BitmapMetadata)img.Metadata;
// MetaData
MetaData += "Title: " + meta.Title + Environment.NewLine;
MetaData += "Subject: " + meta.Subject +
Environment.NewLine;
MetaData += "Comment: " + meta.Comment +
Environment.NewLine;
MetaData += "Date taken: " + meta.DateTaken +
Environment.NewLine;
MetaData += "Authors: " + meta.Author +
Environment.NewLine;
/* Image data */
double mpixel = (img.PixelHeight * img.PixelWidth) /
(double)1000000;
MetaData +="Image Width: "+ img.PixelWidth + "px"+
Environment.NewLine;
MetaData +="Image Height: "+ img.PixelHeight + "px"+
Environment.NewLine;
MetaData +="Megapixels: " + mpixel +
Environment.NewLine;
MetaData += "DPI: " + img.DpiX + img.DpiY
+Environment.NewLine;
// More Metadata
MetaData += "Camera Maker: " + meta.CameraManufacturer +
Environment.NewLine;
MetaData += "Camera Model: " + meta.CameraModel +
Environment.NewLine;
MetaData += "Edited in: " + meta.ApplicationName +
Environment.NewLine;
MetaData += "Copyright: " + meta.Copyright +
Environment.NewLine;
// remove unsafe characters for ajax postback
MetaData = MetaData.Replace ("<","");
MetaData = MetaData.Replace (">","");
return MetaData ;
}
This is the code i have been trying to write the data with out sucess
imageFile = "c://users//roger//documents//test.jpg";
bool done = true;
Stream jpgStream = new System.IO.FileStream(imageFile,
FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
JpegBitmapDecoder jpgDecoder = new
JpegBitmapDecoder(jpgStream,
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapFrame jpgFrame = jpgDecoder.Frames[0];
InPlaceBitmapMetadataWriter jpgInplace =
jpgFrame.CreateInPlaceBitmapMetadataWriter();
if (jpgInplace.TrySave() == true)
{
jpgInplace.SetQuery("/Text/Title", "Have a nice
day");
}
jpgStream.Close();
--------------------------------------------------------------------------------------------------------
Hi Roger,
Can you post the code piece so that i will have more clarity on as
to
what
are you trying to do and hence will be more accomplished to give my
inputs
for the same.
regards,
Joy
:
Thanks for the link.
I have looked there and tried a few examples that i have found
oround
the
net.
It seems that its all a little sketchy, and i have yet to find any
one
who
have got this to work.
I have found a c# libray which i am looking into now but it seems
that
the
EXIF standard and MS standard are different.
If you change the tags in Vista they do not seem to match the EXIF
format.
I have spent the weekend looking into this and am able to read
tags
with
no
problem at all.
Writing to the tags seems a whole different ball game.
I will keep trying.
Anymore suggestions would be welcome.
If I find away to make this work i will post the soloution.
Great New group by the way I will try and participate
Thanks again for the suggestions
Roger
Hi Roger,
Let me know if the following link was of any help to you:
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapmetadata.aspx
regards,
Joy
:
Hi all
I have managed read metadata from an image file using
BitmapMetaData,
and
that works fine,
but I am having trouble finding out how to write the
information
back
to
the
Image
can anyone help with this please
Thanks in advance
Roger