50,527
社区成员
发帖
与我相关
我的任务
分享
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import mediautil.gen.Rational;
import mediautil.image.jpeg.Entry;
import mediautil.image.jpeg.Exif;
import mediautil.image.jpeg.LLJTran;
import mediautil.image.jpeg.LLJTranException;
public class exifTestwrit {
/**
* 将照片中的信息进行重写
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
LLJTran llj = new LLJTran(new File("E:\\dd.jpg"));
readImage(llj, true, LLJTran.READ_INFO, 0, 0);
// llj.closeInternalInputStream();
String newTime = "";
Exif exif = (Exif) llj.getImageInfo();
Entry entry = exif.getTagValue(Exif.DATETIME, true);
if(entry != null)
entry.setValue(0, "1998:08:18 11:15:00");
entry = exif.getTagValue(Exif.DATETIMEORIGINAL, true);
if(entry != null)
entry.setValue(0, "1998:08:18 11:15:00");
entry = exif.getTagValue(Exif.DATETIMEDIGITIZED, true);
if(entry != null)
entry.setValue(0, "1998:08:18 11:15:00");
entry = exif.getTagValue(Exif.ORIENTATION, true);
System.out.println("Orient Entry = " + entry);
if(entry != null)
entry.setValue(0, new Integer(6));
llj.refreshAppx();
// FileInputStream fip = new FileInputStream("Img_1217.jpg");
FileOutputStream nhOp = new FileOutputStream("c:\\new_2.jpg");
llj.xferInfo(null, nhOp, LLJTran.REPLACE, LLJTran.REPLACE);
// fip.close();
nhOp.close();
}
public static void readImage(LLJTran llj, boolean keep_appxs, int stage1, int stage2, int stage3)throws LLJTranException
{
if(stage1 != 0)
llj.read(stage1, keep_appxs);
if(stage2 != 0)
llj.read(stage2, keep_appxs);
if(stage3 != 0)
llj.read(stage3, keep_appxs);
System.out.println("Successfully Read Image");
}
}