Browse Source

Replace icafe with apache-commons-imaging

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
60e5007376
  1. 3
      app/build.gradle
  2. 10
      app/src/main/java/awais/instagrabber/workers/DownloadWorker.java
  3. 1
      build.gradle

3
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'

10
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()

1
build.gradle

@ -16,7 +16,6 @@ allprojects {
google()
jcenter()
mavenCentral()
maven { url 'http://maven.geotoolkit.org/' }
maven { url 'https://jitpack.io' }
}
}

Loading…
Cancel
Save