java 消除png 锯齿_如何在Java中删除png图像的Exif,IPTC,XMP数据

我们正在尝试删除png图像的Exif,IPTC和XMP数据 . 请提供相同的示例代码

我们有一个png图像文件 .

需要删除Exif,IPTC和XMP数据 .

package com.test;

import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream;

import org.apache.commons.imaging.ImageReadException; import org.apache.commons.imaging.ImageWriteException; import org.apache.commons.imaging.formats.jpeg.iptc.JpegIptcRewriter;

class ImageUploadTest {

public static void main(String[] args) {

try {

final File original = new File(

"/Users/anupam256093/Downloads/Test.png");

final File newimage = new File(

"/Users/anupam256093/Downloads/Test_resized2.png");

removeExifTag(original, newimage);

} catch (Exception e) {

System.out.println(e.getMessage());

System.out.println(e);

}

}

public static void removeExifTag(final File jpegImageFile, final File dst) {

OutputStream os = null;

OutputStream osiptc = null;

try {

System.out.println("4");

os = new FileOutputStream(dst);

os = new BufferedOutputStream(os);

System.out.println("15");

osiptc = new FileOutputStream(dst);

osiptc = new BufferedOutputStream(osiptc);

new JpegIptcRewriter().removeIPTC(jpegImageFile, os);

// new ExifRewriter().removeExifMetadata(jpegImageFile, os);

System.out.println("15");

//new PngWriter(true).writeImage(jpegImageFile, os, null);

//System.out.println("16");

os.close();

os = null;

System.out.println("7");

System.out.println("SUCCESS");

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

System.out.println("ERROR");

e.printStackTrace();

} catch (ImageWriteException e) {

// TODO Auto-generated catch block

System.out.println("ERROR1");

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

System.out.println("ERROR2");

e.printStackTrace();

} catch (ImageReadException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} finally {

if (os != null) {

try {

os.close();

} catch (final IOException e) {

}

}

}

}

}

我们正在尝试删除png图像的Exif,IPTC和XMP数据 . 请提供相同的示例代码

我们有一个png图像文件 .

需要删除Exif,IPTC和XMP数据 .


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部