c# - Using ExifLib on remote images -


i have application displays images stored remotely on twitter, instagram , flickr's servers. use exiflib extract exif information (mainly gps data) , display them image details.

here have far:

string metadata = string.empty; string tagvalue = string.empty;  try {     using (var wc = new webclient())     {         byte[] imagebytes = wc.downloaddata(imgurl);          using (var ms = new memorystream(imagebytes, 0, imagebytes.length))         {             using (exifreader reader = new exifreader(ms))             {                 if (reader.gettagvalue<string>(exiftags.gpsaltitude, out tagvalue))                     log.debug("gpsaltitude: " + tagvalue);                  if (reader.gettagvalue<string>(exiftags.datetimedigitized, out tagvalue))                     log.debug("datetimedigitized: " + tagvalue);                  if (reader.gettagvalue<string>(exiftags.datetimeoriginal, out tagvalue))                     log.debug("datetimeoriginal: " + tagvalue);                  if (reader.gettagvalue<string>(exiftags.gpslatitude, out tagvalue))                     log.debug("gpslatitude: " + tagvalue);                  if (reader.gettagvalue<string>(exiftags.gpslongitude, out tagvalue))                     log.debug("gpslongitude: " + tagvalue);              }         }     } } catch (exception ex) {     log.exception("a problem occurred while fetching exif data.", ex); } 

but every imageurl goes through seems not past instantiating exifreader image's memorystream; hits exception , indicates exiflib not find exif data, when pick an image flickr has exif data.

am doing wrong in code above or exiflib not work on remote images?

have tried checking if imagebytes contains valid data? save file , see if repeating function actual file changes anything. maybe download doesn't succeed, have lot of activity in try..catch.

as workaround first save data in temporary file on server , use that. know want avoid that, better working nothing. , log intermediate results on server can distinguich , debug many possible defects (like wrong url or flickr not wanting exceed amount of downloads per minute).


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -