dragon66 / icafe

Java library for reading, writing, converting and manipulating images and metadata
Eclipse Public License 1.0
203 stars 58 forks source link

copy metadata from raw to jpg failed. #108

Closed ivanooi closed 2 years ago

ivanooi commented 2 years ago

Hi,

from my test. I'm able to read the metadata from raw file but it failed to write it into jpg file. There;s no error. but when I check the metadata. XMP and Exif missing.

thanks

sample jpg and raw file https://drive.google.com/file/d/1sK7f_-rZd4-IVlrHVj8086kVPb33OE-d/view?usp=sharing

test_icafe.java.zip

`

       Map<MetadataType, Metadata> metadataMap ;

       try {
           List<Metadata> metaList = new ArrayList<Metadata>();

           metadataMap = Metadata.readMetadata( src );

           for (Map.Entry<MetadataType, Metadata> entry : metadataMap.entrySet()) {
               System.out.println("metaList="+metaList.add( entry.getValue()));
               System.out.println(entry.getValue().getType().name());
           }

// System.out.println( des.getAbsoluteFile().getParent()); File lfnew = new File( des.getAbsoluteFile().getParentFile().getAbsolutePath() + "/" + des.getName() + ".new"); // File lftemp = new File( des.getAbsoluteFile().getParentFile().getAbsolutePath() + "/" + des.getName() + ".TMP");

// if( des.renameTo( lf_temp ) == false ){ // return "rename failed"; // }

           FileInputStream  fin = new FileInputStream( des );
           FileOutputStream fout= new FileOutputStream( lf_new );

// FileInputStream fin = new FileInputStream( lf_temp ); // FileOutputStream fout= new FileOutputStream( des );

           Metadata.insertMetadata( metaList, fin, fout );

           fin.close();
           fout.close();

// lf_temp.delete();

       } catch (IOException e) {
           e.printStackTrace();
           return e.toString(); 
       }

`

ivanooi commented 2 years ago

ok. I had solved the issues. thanks :-D.

Exif exif2 = new JpegExif();

exif2.setExifIFD( orifinalExif1.getExifIFD());