 |
|
 |
Can you use this library to set properties? Also, is it possible to define your own properties? thanks
|
|
|
|
 |
|
 |
it's working very well in C#!
Nima
|
|
|
|
 |
|
 |
Can I build an application uses your EXIFextractor.dll ?
Of course, my application is not for commercial purpose, but I may release it for free and ask users don't use it to make money.
I hope your answer is positive.
Thanks
Jack Chi-Chang Hsu
Taipei,Taiwan
|
|
|
|
 |
|
 |
You can copy, reuse or change it without any restrictions. It is absolutely free.
|
|
|
|
 |
|
 |
Hi
Great stuff, but I've a bit of a problem.
I've written a classs to save uploaded images, using your library to get the metadata. Something like this:
Me.PostedFile.SaveAs(strOutPut)
Me.PostedFile = Nothing
dim strMetaInfo as string
strMetaInfo = getProperties("/" & Me.RootFolder & Me.ScrapFolder & "/" & Me.strFileName)
..... // code to resize, rotate etc.
Function getProperties(ByVal strImage As String) As String
Dim inf As New Info(HttpContext.Current.Server.MapPath(strImage))
Dim propertyName As String
Dim strProps As String = ""
For Each propertyName In inf.PropertyItems.Keys
strProps += propertyName & ": " & inf.PropertyItems(propertyName).ToString amp; "<br/>"
Next
getProperties = strProps
inf = Nothing
End Function
The trouble is if I try to upload the file again, I get the error:
the process cannot access the file "x.jpg" because it is being used by another process
I've a feeling the Info class isn't dispose()ing of something correctly.
Thanks again
Johnie
|
|
|
|
 |
|
 |
Hi again
I solved this one myself, by adding the following to Info.cs
public void getrid() {
_image.Dispose();
}
See here http://www.odetocode.com/Articles/417.aspx[^][^]
for simple notes on how to recompile on the command line.
My code now goes
Function getProperties(ByVal strImage As String) As String
Dim inf As New Info(HttpContext.Current.Server.MapPath(strImage))
Dim propertyName As String
Dim strProps As String = ""
For Each propertyName In inf.PropertyItems.Keys
strProps += propertyName & ": " & inf.PropertyItems(propertyName).ToString amp; "<br/>"
Next
getProperties = strProps
inf.getrid()
inf = Nothing
End Function
Johnie
|
|
|
|
 |
|
 |
Can I use this in an application that may eventually be commercial?
|
|
|
|
 |
|
 |
This code is free for use, copy and duplicate modified or unmodified. The only requirement is a positive vote!
|
|
|
|
 |
|
 |
Hi there
Firstly I want to thank you very much for this article. I was very happy when I found it. It seemed to fit the glove perfectly for what I was looking to do, and it works *almost* all the time. However.. something is happening that has me stumped. Maybe it's simple since I 'm definitely no guru.
All the pictures that I've been playing with so far were all taken with the same camera and have been subject to the same process to download them off of the camera.
I can access the EXIF data from most pictures, but there is a small group of pictures that it doesn't seem to read the data for.. I'd like to focus in on the "DtOrig" property since that is the one I'm most interested in, and the one that is particularly confusing. I thought originally that it was an error in my code (which uses your .dll) but then after tangling with it for awhile I tried your demo on the files and the demo also cannot read the DTOrig data on the particular files in question.
Fine then you say, the data just isn't there. But I'm using Vista, and when I right-click on the picture, and go to the Details tab, the data is correctly displayed there - so I'm thinking it is definitely encoded in the file.
I'm hoping that you can help me figure out how to get the data out of these files.
If it is helpful, I'll post one of these mysterious pictures, and you can try it out yourself.
Thanks for any help.
|
|
|
|
 |
|
 |
Hi,
send me a picture having the described problem. I'll try to find out why it does heppens.
|
|
|
|
 |
|
 |
Hi George
I've posted the pictures here and named them appropriately:
http://cid-a941f66695c4da22.skydrive.live.com/browse.aspx/test/exif_data_problem[^]
ie:
picture1_DataFound.jpg <-- DTOrig is viewable in both windows and the demo program
picture2_DataNotFound.jpg <-- DTOrig is viewable in windows but not in the demo program
The pictures are of our new little baby boy
Thanks again for taking a look.
Todd
|
|
|
|
 |
|
 |
Sorry, it seems I am not able to help you. The problem occurs when reading apropriate image properties from raw file using .NET native metod.
System.Drawing.Image.GetPropertyItem
Either there is a bug in you camera or in framework itself. I hate conclusions like this but it seems to be right in this case.
I wish you and your new born young man everithing all the best! I would not say he is little
|
|
|
|
 |
|
 |
Hi George
Thanks for looking into it.
I found a post on an msdn blog that *might* provide a clue as to why Vista knows the original date taken, and it is not readable in the exif data.
I noticed that the EXIF 'Software' property said "Microsoft Windows Photo Gallery 6.0.6000.16386" That is the software used to download the pictures from the camera, and it may also be an ominous signature leading back to the cause of my problem.
That value indicates to me that the camera is not the only one writing to the EXIF data, and if photo gallery is writing to the EXIF data, maybe it has some hand in messing up the DTOrig value. Especially since, the vista file 'Details' tab is presumably reading from the XMP data, and IT contains the correct date taken.
The only place I figure photo gallery can get the DTOrig value in the first place is from the EXIF data, since the camera clearly wouldn't know how to write to both EXIF and XMP.
So.. following this theory, Windows Photo Gallery is using the DTOrig and copying it into the XMP formatted metadata and in doing so, somehow corrupting the DTOrig EXIF data - making it unreadable by yours or any other EXIF reader I've tried.
SO... all that being said, I'm going to try and experiment some more to explore my idea, and find a way to read that XMP meta data from the file.
Here's the blog post I referrerd to. If you have any insights, ideas, or advice, it's most certainly welcome.
http://blogs.msdn.com/pix/archive/2006/08/16/702780.aspx[^]
-Todd
|
|
|
|
 |
|
 |
I managed to extract the XMP data from the file.
If you open the jpg in notepad, you can see it right there in plain text.
I wrote the code to get the DTOrig value based off of this guys example.
[^]
So in my code, I check the exif property, and if it isn't available then I read the xmp data, and look for the data there.
I'm not sure why MS would do a destructive read on the DTOrig exif property value. Maybe it's some kind of bug, but that wouldn't be very likely since Microsoft stuff never has bugs.
|
|
|
|
 |
|
 |
This is very useful. I'm needed to get info from photo and this is just what I need .
Excellent job!
Thank you.
Regards,
Davorin!
|
|
|
|
 |
|
 |
I agree, spent ages pissing about in the gdi+ before finding this article
|
|
|
|
 |
|
 |
Hi,
thanks for the code,
I wrote an aplication that use this dll
http:\\www.upload.co.il\eng\creation.asp?id=424
|
|
|
|
 |
|
 |
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
|
|
|
|
 |