c# - Upload is stripping image metadata MVC5 -


i have simple file upload adding images record in our business app. issue after file uploaded , in c# controller not have exif data image. not doing special just:

html

<form action="/image/upload" method="post" enctype="multipart/form-data"> <input type="file" class="form-control" style="width:80%" name="photo" accept="image/*" capture="camera" />             <input type="hidden" name="clientid" id="hvclientid" />             <input type="submit" class="btn btn-primary btn-xs" value="upload"/>         </form> 

controller

[httppost]     public actionresult upload(httppostedfilebase photo, formcollection items)     {          string clientid = items[0].tostring();          var tempimg = image.fromstream(photo.inputstream);         if (imagetools.determineifimagesizeabovemax(tempimg))             tempimg = imagetools.resize(tempimg, imagetools.imagesize.large);          var exif = new exif();         var img = exif.fixorientation(tempimg);          var azure = new azure.blob.consumer.storageconsumer(clientid, azure.storagebase.myapp);         var tempuri = azure.cacheimage(img, photo.filename);          return json(new { path = tempuri });     } 

the tempimg variable not contain exif metadata present on original file. exif class lib wrote things fix orientation etc.

fetching attributes azure storage before setting properties might retain exif data while uploading image.

cloudblockblob blob = samplecontainer.getblockblobreference(photo.filename); blob.fetchattributes(); blob.properties.contenttype = "image/jpg"; blob.setproperties(); 

also make sure image contain's necessary exif data before uploading. (in case sending image through chat app removed exif data image.) please refer this blog more info


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -