From 60e50073762b32c4cd480d175afd1e912823f3fa Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Tue, 10 Nov 2020 21:43:53 +0900 Subject: [PATCH] Replace icafe with apache-commons-imaging --- app/build.gradle | 3 +-- .../awais/instagrabber/workers/DownloadWorker.java | 10 ++++++---- build.gradle | 1 - 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b4f2367b..08fa6400 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -80,8 +80,7 @@ dependencies { implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' - implementation 'com.github.dragon66:icafe:master-SNAPSHOT' - implementation 'javax.media:jai_imageio:1.1.1' + implementation 'org.apache.commons:commons-imaging:1.0-alpha2' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.5' diff --git a/app/src/main/java/awais/instagrabber/workers/DownloadWorker.java b/app/src/main/java/awais/instagrabber/workers/DownloadWorker.java index 1468efe8..542c3408 100644 --- a/app/src/main/java/awais/instagrabber/workers/DownloadWorker.java +++ b/app/src/main/java/awais/instagrabber/workers/DownloadWorker.java @@ -26,8 +26,8 @@ import androidx.work.WorkerParameters; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; -import com.icafe4j.image.meta.Metadata; -import com.icafe4j.image.meta.MetadataType; + +import org.apache.commons.imaging.formats.jpeg.iptc.JpegIptcRewriter; import java.io.BufferedInputStream; import java.io.File; @@ -89,6 +89,7 @@ public class DownloadWorker extends Worker { try (Scanner scanner = new Scanner(requestFile)) { downloadRequestString = scanner.useDelimiter("\\A").next(); } catch (Exception e) { + Log.e(TAG, "doWork: ", e); return Result.failure(new Data.Builder() .putString("error", e.getLocalizedMessage()) .build()); @@ -170,9 +171,10 @@ public class DownloadWorker extends Worker { } if (isJpg) { final File finalFile = new File(filePath); - try (FileInputStream bis = new FileInputStream(outFile); + try (FileInputStream fis = new FileInputStream(outFile); FileOutputStream fos = new FileOutputStream(finalFile)) { - Metadata.removeMetadata(bis, fos, MetadataType.IPTC); + final JpegIptcRewriter jpegIptcRewriter = new JpegIptcRewriter(); + jpegIptcRewriter.removeIPTC(fis, fos); } catch (Exception e) { Log.e(TAG, "Error while removing iptc: url: " + url + ", tempFile: " + outFile.getAbsolutePath() diff --git a/build.gradle b/build.gradle index da4ac225..18c01d6e 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,6 @@ allprojects { google() jcenter() mavenCentral() - maven { url 'http://maven.geotoolkit.org/' } maven { url 'https://jitpack.io' } } }