|
Hi.
How would I go about integrating this library into a Xamarin.Forms AppShell mobile App. I am getting all sorts of errors by just adding ExifMetaData.dll into my Assemblies section of app. Too many errors to list. Any guidance please?
|
|
|
|
|
I want same application in php or javascript..
|
|
|
|
|
Hi Dev;
Very interesting code.
All my images are stored in a SQL table as varbinary blobs. In the C# I retrieve the binary image data into a C# byte array.
I would like to instantiate the ExifTagCollection object from a byte array something like this:
ExifTagCollection exif = new ExifTagCollection(bytearray[]);
I can't convert the byte array back to a file stream object because it would kill performance in my application.
Is it possible?
Thanks in advance.
-Larry
|
|
|
|
|
I found a way to convert to a stream object that doesn't cost too much. Works well enough:
byte[] image = dbm.GetImageView(id);
MemoryStream imgMemoryStream = new MemoryStream(image);
Image myImage = Image.FromStream(imgMemoryStream);
ExifTagCollection exif = new ExifTagCollection(myImage);
Thanks.. great little class there.
There is a "gotcha" when looking for specific property that the indexer doesn't return , but a simple try/catch fixed that issue:
public ExifTag this[int id]
{
get
{
try
{
return _tags[id];
}
catch { return null; }
}
}
|
|
|
|
|
Hello there! I found your solution very usefull. I had developed an application to write the metadata from my trip photos into a shape file so I can put them on a map, but I got a little problem. Can you make your dll to read ricoh rmeta tags? I need that tags because there I can write different infos like string (name, observations etc.)
Thank you!
|
|
|
|
|
it does not work for large files like 50MB jpeg files. can you resolve this
Thanks
|
|
|
|
|
I'm using this library in a freeware project and it works perfectly. Thanks!
|
|
|
|
|
This is a nice and useful library. I can handle all my jpeg images with it. But it would be very nice if i can handle my dng images too. Now I get some infos about make, model and software, but no infos about exposure time, F number or focal length. The shown image width and height seems to be those of the embedded thumbnail.
Is it hard for you to get the infos out of a raw image?
Thomas
|
|
|
|
|
Great work, code worked perfectly, thanks very much!
|
|
|
|
|
Thanks for sharing. Cool.
|
|
|
|
|
|
I used it to add exif data to the photos of my web gallery.
Thank you.
Stefan
|
|
|
|
|
you could set the PropertyItem.Value, then save the image.
Regards,
unruledboy_at_gmail_dot_com
http://www.xnlab.com
|
|
|
|
|
Your code works, but unfortunately it isn't a lossless operation i.e. you will lose some data by saving it back again (as well as it taking some time to save the data).
|
|
|
|
|
I'm making a asp.net project where I want the user uploads a jpeg file and process it by adding GPS info. to its EXIF tag and let the user download it.
Whatever,I tried using the EXIFExtractor to read exif info and use the settag() mathod such way to add GPS to exif:
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(strfilename);
Goheer.EXIF.EXIFextractor er = new Goheer.EXIF.EXIFextractor(ref bmp, "");
er.setTag(0x0, "2");//gps ver
er.setTag(0x1, "N");//lat. ref
er.setTag(0x2, "108.11223344");//latitude
er.setTag(0x3, "E");//long. ref
er.setTag(0x4, "34.11223344");//longitude
er.setTag(0x7, "0/0");//gpstime
bmp.Save(strnewfilename);
then I use EXIFExtractor to read the new exif,it seems worked.I can read the GPS info from the processed file.
BUT,when I used other software which can read GPS info and locate the photo on google map to read the processed file,it failed, the GPS info in the processed file can't be read out....
I'm wondering if I can't using the EXIFExtracor.settag() method to simply add a string varible such as "108.11223344" to make my idea work?
Any suggestions?
I've download your code and will try it later,hope it helped.
Thanks very much whatever
|
|
|
|
|
Hi,
Well, actually the ExifExtractor doesn't have SetTag method (yet, I still don't have enough time to get back to the code and implement the tag writing code).
I haven't checked Asim Goheer code for SetTag method (I assume from the code, you are using his code for setting the tags' values), so you better contact him for the details, or check his code to see how the values are being set.
All I can say is that I tested the GPS tag extraction on various images (including some images that actually work with online services, like google, and standalone applications, like ACDSee or XnView), and everything worked just fine.
Lev
|
|
|
|
|
thanks very much for reply
I'm very sure your code can work perfectly!
However,I just want to write the GPS information into EXIF correctly,have you ever tried?
Thanks a again.
Best wishes.
|
|
|
|
|
You're welcome.
No unfortunately I've never written GPS tags by code.
I've used images with GPS data embedded by cameras or PDAs.
Regards,
Lev
|
|
|
|
|
hi,buddy!
i've looked at your code about the GPS part and also the EXIF Standards,for example,the GPS Latitude's description as below:
GPSLatitude
Indicates the latitude. The latitude is expressed as three RATIONAL values giving the degrees, minutes, and
seconds, respectively. If latitude is expressed as degrees, minutes and seconds, a typical format would be
dd/1,mm/1,ss/1. When degrees and minutes are used and, for example, fractions of minutes are given up to two
decimal places, the format would be dd/1,mmmm/100,0/1.
Tag = 2 (2.H)
Type = RATIONAL
Count = 3
Default = none
and you use a GPSRational(which accpect byte[]) to parse the GPS info,such as GPS Latitude,which has a propertyitem.id=0x2 and propertyitem.len=24(8*3).
for now, i just want modify the GPS Latitude info,so i create a byte[] t, and assign its value like this:
byte[] t = new byte[24];
t[0] = 34;
t[1] = 0;
t[2] = 0;
t[3] = 0;
t[4] = 1;
t[5] = 0;
t[6] = 0;
t[7] = 0;
t[8] = 47;
t[9] = 0;
t[10] = 0;
t[11] = 0;
t[12] = 1;
t[13] = 0;
t[14] = 0;
t[15] = 0;
t[16] = 195;
t[17] = 2;
t[18] = 0;
t[19] = 0;
t[20] = 20;
t[21] = 0;
t[22] = 0;
t[23] = 0;
then use the setpropertyitem() method "successfully" change the image's GPS Latitude info. like this:
PropertyItem pi = img.GetPropertyItems(0x2);
pi.Type = 5;
pi.Len = 24;
pi.Id = 0x2;
pi.Value = t;
then use your demo and my own demo to check the image's GPS Latitude info,it appears right result:89d47m35.22s
BUT AGAIN,i use the third party software which can locate the photo on google map to check this image,and nothing happened,its gps info doesn't exit...
I guess something wrong occured when i assgin value to the byte[] t above, but i haven't found a solution yet.
but i'll continue to try fix this,although i'm not an experienced coder.
If you are interested in this about writing gps info to photos sometimes later, please share it here, i'll so glad to see the updates.
If i found some useful issues sometimes later, i'll also bring them here too.
Best wishes
|
|
|
|
|
I did it
the EXIF standard book specifies the data source are byte[],so propertyitem.value return byte[]. To assign such type of value must do some convertion rather than simply use "=".
these codes works:
System.Drawing.Imaging.PropertyItem pi = System.Drawing.Image.FromFile(@"C:\Documents and Settings\Wang Zhifang\桌面\my gps\exif_source_demo\Demo\EXIFextractor.decoy.jpg").PropertyItems[0];
pi.Type = 5;
pi.Len = 24;
pi.Id = 0x2;
pi.Value = new byte[24];
//construct .value
byte[] n = new byte[4];//numerator
byte[] d = new byte[4];//denominator
n = BitConverter.GetBytes(34);
d = BitConverter.GetBytes(1);
Array.Copy(n, 0, pi.Value, 0, 4);
Array.Copy(d, 0, pi.Value, 4, 4);
n = BitConverter.GetBytes(47);
Array.Copy(n, 0, pi.Value, 8, 4);
Array.Copy(d, 0, pi.Value, 12, 4);
n = BitConverter.GetBytes(707);
d = BitConverter.GetBytes(20);
Array.Copy(n, 0, pi.Value, 16, 4);
Array.Copy(d, 0, pi.Value, 20, 4);
bmp.SetPropertyItem(pi);//纬度
//经度
//create propertyitem
pi.Type = 5;
pi.Len = 24;
pi.Id = 0x4;
pi.Value = new byte[24];
//construct .value
n = BitConverter.GetBytes(108);
d = BitConverter.GetBytes(1);
Array.Copy(n, 0, pi.Value, 0, 4);
Array.Copy(d, 0, pi.Value, 4, 4);
n = BitConverter.GetBytes(25);
Array.Copy(n, 0, pi.Value, 8, 4);
Array.Copy(d, 0, pi.Value, 12, 4);
n = BitConverter.GetBytes(707);
d = BitConverter.GetBytes(20);
Array.Copy(n, 0, pi.Value, 16, 4);
Array.Copy(d, 0, pi.Value, 20, 4);
bmp.SetPropertyItem(pi);//纬度
//设置经纬度参考
System.Drawing.Imaging.PropertyItem ppii = System.Drawing.Image.FromFile(@"C:\Documents and Settings\Wang Zhifang\桌面\my gps\exif_source_demo\Demo\EXIFextractor.decoy.jpg").PropertyItems[0];
ppii.Id = 0x1;//纬度参考
ppii.Len = 2;//以null结尾
ppii.Type = 2;
ppii.Value=new byte[2];
byte[] cref=new byte[2];
cref = System.Text.Encoding.ASCII.GetBytes("N\0");
Array.Copy(cref, 0, ppii.Value, 0, 2);
bmp.SetPropertyItem(ppii);
//设置经经度参考
ppii.Id = 0x3;//经度参考
ppii.Len = 2;//以null结尾
ppii.Type = 2;
cref = System.Text.Encoding.ASCII.GetBytes("E\0");//\0是经过转义的字符,会自动变成字符串的结尾,默认的string没有这个结尾
Array.Copy(cref, 0, ppii.Value, 0, 2);
bmp.SetPropertyItem(ppii);
the codes set the value of 4 items:GPS Lat.,GPS Long., GPS Lat.Ref, GPS Long.Ref,the specific value bases on the propertyitem.type,could be refer to MSDN or EXIF standard.
Finally,thanks for your code, and wish you all the best in your work
|
|
|
|
|
Hi,
You're welcome. And thanks for your research, I haven't had time to look into it, but I'll have it in mind.
Lev
|
|
|
|
|
A very, very useful bit of code. Thanks.
Here's an oddity you might be interested in. The first image I tried the code on was a Jpeg created in Photoshop.
It crashed in ExifTagCollection.ReadTags() trying to add a duplicate tag to the tag collection. Evidently my image has some duplicated Exif data.
I fixed it simply by changing:
_tags.Add(tag.Id, tag);
to
if (_tags.ContainsKey(tag.Id))
{
_tags[tag.Id] = tag;
}
else
{
_tags.Add(tag.Id, tag);
}
It may not be reasonable for duplicate tags to exist in the Exif, but this was created in Photoshop CS3, so it's likely to happen again.
Cheers,
Steve
|
|
|
|
|
Hi, Steve,
I do not have a Photoshop CS3, could you please send me a sample file?
Lev
PS. I don't like the ContainsKey(), I'll try to find something more efficient
|
|
|
|
|
Reading tags is very inefficient.
Why you try to load all supported tags from any image, and then eating exceptions? This is not only bad design but slow too.
Why not enumerate not all possible tags, but only existent tags? Check Image.PropertyItems property.
Liberavi animam meam!
|
|
|
|
|
Thanks, Eugene,
The problem is that PropertyItems contains a lot of stuff that has nothing to do with EXIF. So traversing through it will bring up the same problems.
I'm thinking of a better way to solve this problem. One possible way would be having a separate list of supported tags as a Hashtable (as it doesn't raise an exception when a non-existent key is being read) and checking for a null afterwards.
I think I will update the code soon to avoid that exceptions soon...
|
|
|
|
|