 |
|
 |
Thanks...this is great and saved me a ton of effort! I did run into an issue though - once I accessed the metadata I tried to modify the tiff ResolutionUnit. The default seems to be 2 and I wanted to change it to a 1. It appears to allow and retain the change during runtime, but once I save the image it appears to default back to 2. I can't quite tell what I am doing wrong...any help I can get would be much appreciated.
prop.Id = 296;
prop.Value[0] = 1;
tiffImage.SetPropertyItem(prop);
tiffImage.Save(@"D:\Work\Trial\ImageConversion\Bitonal\Images\8.tif");
rm
|
|
|
|
 |
|
 |
Firstly thanks, oh thanks, oh thanks for a superb class. This has saved my a lot of time.
I came across a couple of optimizations that I thought you might be interested in.
Firstly I took out the _image reference and added a
private PropertyItem[] _metadata;
so the whole image was not in memory for the scope of info instance.
In addition, I found this article
http://www.pixvillage.com/blogs/devblog/archive/2005/03/17/159.aspx
which provides a quicker method of loading the image data. So I added this function, which your constructor calls
private void FastLoadImage(string imageFileName)
{
using (FileStream stream = new FileStream(imageFileName, FileMode.Open, FileAccess.Read))
using (Image image = Image.FromStream(stream,true,false))
_metadata = image.PropertyItems;
}
I then created a couple of wrapper methods for getting the info from the _metaData variable
private PropertyItem GetMetaData(PropertyTagId tag)
{
PropertyItem item;
for (int i = 0; i < _metadata.Length; i++)
{
item = _metadata[i];
if (item.Id == (int)tag)
return item;
}
return null;
}
private Object GetMetaDataValue(PropertyTagId tag)
{
return PropertyTag.getValue(GetMetaData(tag));
}
which simplifies property call
e.g.
return (Fraction) GetMetaDataValue(PropertyTagId.XResolution);
I managed to extract the metadata from 6288 files in 42 seconds after these changes.
Though you might be interested.
-- modified at 13:59 Wednesday 25th October, 2006
|
|
|
|
 |
|
 |
Hi,
I've downloaded the EXIFextractor.dll but I don't know how to refer to it. Would you please show me how? (I'm asp.Net programmer)
Thanks
|
|
|
|
 |
|
 |
Hi,
first of all add a reference to your ASP.NET project. Then add using gma.Drawing.ImageInfo; at top of your codebehind class. Now you are ready to use it in your page. Add this snippet for example in Page_Load method
Image img = Image.FromFile("c:\test.jpg");
Info inf=new Info(pictureBox.Image);
foreach (string propertyname in inf.PropertyItems.Keys)
{
Response.Write(propertyname,
(inf.PropertyItems[propertyname]).ToString());
}
|
|
|
|
 |
|
 |
Thank you very much for your help.
Now on top of code behind page when I add Imports I can see the gma.Drawing.ImageInfo there. But your example to test the dll I think is not asp.net. Can convert those lines to asp.net syntax (I'm just a beginer)?
Thanks,
Regards
MD
|
|
|
|
 |
|
 |
Thank you,
I've found a gma.Drawing.ImageInfo help. It works now.
Thanks.
MD
|
|
|
|
 |
|
 |
I have used your program to get metadata of images.
When you open the image in Photoshop you will see an owner url field.
I couldn’t find that value from the application.
How do you access that field?
Janaka
|
|
|
|
 |
|
 |
Beings i don't know C that well, is there a way to port this to visual basic? I am trying to massive update all of the datecreated tags with the OriginalDate tag with about 7000 pictures.
Mac
|
|
|
|
 |
|
 |
I can advice you to leave the code on c# compile it as an assembly and refer to it from vb.net.
|
|
|
|
 |
|
 |
Hi,
if You successfully import code in Visual Basic can you send me how it look in VB.
Alen.
|
|
|
|
 |
|
 |
Woud you like to rewrite it in VisualBasic or you want to use it in VisualBasic?
|
|
|
|
 |
|
 |
I wan to use it in VB.
Alen.
|
|
|
|
 |
|
|
 |
|
|
 |
|
 |
The only way I have found to add image meta data within the .net framework is to first use the .GetPropertyItem(...) command and then alter the id and value so that it points to a new location. Then use the .SetPropertyItem(...) and do an image save command. So for example if you wanted to add an image description:
PropertyItem propI = m_Bitmap.GetPropertyItem(269); //Get a PropertyItem from image in
//this case the document name
propI.Id = 270; //change id so that it is now the id for the image description
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); //to convert ascii to
//a byte array
string temp = "Text You Want To Add To The Image Description";
byte[] texttoadd = encoding.GetBytes(temp); //store in byte array
propI.Value = texttoadd; //change value of the PropertyItem.
m_Bitmap.SetPropertyItem(propI); // Set the PropertyItem
m_Bitmap.Save("C:\image.jpg");
This only works if the property item you change exists in the image in the first place. Most of this info, as well as all the common metadata id numbers can be found on the MSDN website. Hope this helps.
-Matt
|
|
|
|
 |
|
 |
how to modify and save date time value?
and another is
I open a jpg from file and update property.
It can't update to the file that I open.
I don't want to save image with another name.
|
|
|
|
 |
|
 |
how to get the MakerNote,ExposureTime,ExposureBias,Flash,UserComment and so on.
thank you.
|
|
|
|
 |
|
 |
inf=new Info(pictureBox.Image);
MessageBox.Show(inf.PropertyItems[PropertyTagId.ExifFlash.ToString()].ToString());
MessageBox.Show(inf.PropertyItems[PropertyTagId.ExifExposureBias.ToString()].ToString());
See the example, pobably you can find an answer even there! :->
|
|
|
|
 |
|
 |
Does anyone know how to properly embed the ICM tag in the JPG's EXIF info? I don't have .Net and find only .Net solutions to decoding the Tag. The tag PropertyTagICCProfile, I presume is the one to fill but I cant figure out in c++ how to decode this byte array on my visual studio 6. I noticed custom tags try to fill this value but Adobe1998.icc wont. It seems to be the only logical tag to embed the color profile name. Any suggestions are appreciated.
Thanks
zBz
ZeroByZero
|
|
|
|
 |
|
 |
I am writing an image app and I need an easy way to view and set the exif data in an image. I will be display and sorting my images based on what is in the exif data. I specifically need to get to the user definable entries of the exif data. The code in this article goes part way, but I don't see how to access other attributes.
Thanks,
Bret
|
|
|
|
 |
|
 |
Hi !
Thanks for the these nice classes, they made my day!
There is one thing I was missing: a dispose method. I was running into trouble, because an imgagefile stays locked until it is completely removed by the gc. This may take a while. I added the Disposable interface to the Info class, so that I can call the release of the ressource as I whish. This solved my locking problem.
Bye
Michael
public class Info : IDisposable
{
......
cutted
......
#region IDisposable Member
public void Dispose()
{
_image.Dispose();
}
#endregion
}
|
|
|
|
 |
|
 |
Hi Michael,
I have the same problem.
I allways get the message "not enough memory".
Please tell me the exactly way, where I must
write the iDisable class.
thanks
greetings from germany
michael too
mimuel
|
|
|
|
 |
|
 |
Very nice code, simple, would suggest adding ImageDescription
///
/// Image description
///
public string ImageDescription
{
get
{
return (string) PropertyTag.getValue(_image.GetPropertyItem((int)PropertyTagId.ImageDescription));
}
}
Then it's easy to a make a web photogallery system
BTW
Freeware utility to write and read the EXIF
http://www.exifer.friedemann.info/
|
|
|
|
 |
|
 |
Does this work.
I seem to get : index was outside the bounds of the array...
|
|
|
|
 |
|
 |
Hi, this article realy heped a lot!!
I also looking for a sort of file header check (I think). I want to check the file type so that I can be sure that a file with the extension jpg is indeed a jpg image inside. Because we work file 100Mb+ file's it's not wanted to open the entire file to perform this check, currently I open the file in .net and get the imagetype to check the content, this is way to resource expensive for the future. I don't have any clue how to start reading this header, what to look for and even if this is a good solution. Anyone who can help me ?
|
|
|
|
 |