android - How to insert Exif information to a new image? -


i create image comes camera on android application:

yuvimage yuv = new yuvimage(     bytearraydatafromcamera,      camera.getparameters().getpreviewformat(),     imagewidth,      imageheight, null);  bytearrayoutputstream out = new bytearrayoutputstream(); yuv.compresstojpeg(new rect(0, 0, imagewidth, imageheight, 100, out); byte[] bytes = out.tobytearray(); bitmap image = bitmapfactory.decodebytearray(bytes, 0, bytes.length); 

and want add exif information it. since i've tried this:

// save image on sd storeimage(image, "image_0.jpg");  string filepath = environment.getexternalstoragedirectory() + "/myfolder/image_0.jpg"; try {     exifinterface exif = new exifinterface(filepath);     exif.setattribute("usercomment", "my custom comment");      exif.saveattributes(); }  catch (ioexception e) {     e.printstacktrace(); } 

the storeimage method:

private boolean storeimage(bitmap imagedata, string filename) {     //get path external storage (sd card)     string iconsstoragepath = environment.getexternalstoragedirectory() + "/myfolder/";     file sdiconstoragedir = new file(iconsstoragepath);      //create storage directories, if don't exist     sdiconstoragedir.mkdirs();      try {         string filepath = sdiconstoragedir.tostring() + filename;         fileoutputstream fileoutputstream = new fileoutputstream(filepath);          bufferedoutputstream bos = new bufferedoutputstream(fileoutputstream);          //choose format if png doesn't suit         imagedata.compress(compressformat.png, 100, bos);          bos.flush();         bos.close();     } catch (filenotfoundexception e) {         log.w("tag", "error saving image file: " + e.getmessage());         return false;     } catch (ioexception e) {         log.w("tag", "error saving image file: " + e.getmessage());         return false;     }     return true; } 

as image created, doesn't have exifinterface information. want know how add new exifinterface created image. how can achieve this?

i know can add rotation in image information add comment it's more complicated. exif class doesn't work correctly... because can read exif information stream can write information. when search information add image info users have same problem you, , know existing libraries add information in image information... when find post give url!!


i can find post, read this!!

tell me if helped , programming!


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -