Closed tiwane closed 3 years ago
@tiwane can you test this? FWIW, when I try to import https://filesamples.com/samples/image/heif/sample1.heif I get
12-07 16:34:54.307 7740 7810 E AndroidRuntime: FATAL EXCEPTION: Thread-6
12-07 16:34:54.307 7740 7810 E AndroidRuntime: Process: org.inaturalist.android, PID: 7740
12-07 16:34:54.307 7740 7810 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
12-07 16:34:54.307 7740 7810 E AndroidRuntime: at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:800)
12-07 16:34:54.307 7740 7810 E AndroidRuntime: at org.inaturalist.android.ImageUtils.resizeImage(ImageUtils.java:411)
12-07 16:34:54.307 7740 7810 E AndroidRuntime: at org.inaturalist.android.ObservationEditor.createObservationPhotoForPhoto(ObservationEditor.java:3106)
12-07 16:34:54.307 7740 7810 E AndroidRuntime: at org.inaturalist.android.ObservationEditor.access$5000(ObservationEditor.java:130)
12-07 16:34:54.307 7740 7810 E AndroidRuntime: at org.inaturalist.android.ObservationEditor$42.run(ObservationEditor.java:2974)
12-07 16:34:54.307 7740 7810 E AndroidRuntime: at java.lang.Thread.run(Thread.java:923)
12-07 16:34:54.343 7740 7798 E ImageUtils: Crashed while using SmoothRescale library - resizing using Android OS
12-07 16:34:54.343 7740 7798 E ImageUtils: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Bitmap$Config android.graphics.Bitmap.getConfig()' on a null object reference
12-07 16:34:54.343 7740 7798 E ImageUtils: at com.schokoladenbrown.Smooth.rescale(Smooth.java:48)
12-07 16:34:54.343 7740 7798 E ImageUtils: at org.inaturalist.android.ImageUtils.resizeImage(ImageUtils.java:407)
12-07 16:34:54.343 7740 7798 E ImageUtils: at org.inaturalist.android.ObservationEditor.createObservationPhotoForPhoto(ObservationEditor.java:3106)
12-07 16:34:54.343 7740 7798 E ImageUtils: at org.inaturalist.android.ObservationEditor.access$5000(ObservationEditor.java:130)
12-07 16:34:54.343 7740 7798 E ImageUtils: at org.inaturalist.android.ObservationEditor$42.run(ObservationEditor.java:2974)
12-07 16:34:54.343 7740 7798 E ImageUtils: at java.lang.Thread.run(Thread.java:923)
12-07 16:34:54.343 7740 7798 E GlobalExceptionHandler: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
12-07 16:34:54.343 7740 7798 E GlobalExceptionHandler: at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:800)
12-07 16:34:54.343 7740 7798 E GlobalExceptionHandler: at org.inaturalist.android.ImageUtils.resizeImage(ImageUtils.java:411)
12-07 16:34:54.343 7740 7798 E GlobalExceptionHandler: at org.inaturalist.android.ObservationEditor.createObservationPhotoForPhoto(ObservationEditor.java:3106)
12-07 16:34:54.343 7740 7798 E GlobalExceptionHandler: at org.inaturalist.android.ObservationEditor.access$5000(ObservationEditor.java:130)
12-07 16:34:54.343 7740 7798 E GlobalExceptionHandler: at org.inaturalist.android.ObservationEditor$42.run(ObservationEditor.java:2974)
12-07 16:34:54.343 7740 7798 E GlobalExceptionHandler: at java.lang.Thread.run(Thread.java:923)
@budowski when I try to add an obs by importing https://filesamples.com/samples/image/heif/sample1.heif I get an error dialog about the file format, but it says iNat only supports JPG/JPEG/PNG/HEIC/HEIF extensions. That file has an .heif
extension, so what's the problem? Can we improve the error message?
The problem is that not all types of HEIF are supported by Android. What do you think a proper description should be? e.g. If we detect it's an HEIF extension, but still can't load it, we'll show an error like "Android does not support this type of HEIF file"?
How about we just replace
<string name="invalid_photo_extension">Error importing photo(s): Can only import photo files with JPG/JPEG/PNG/HEIC/HEIF extensions</string>
with
<string name="invalid_photo">Photo format not supported</string>
and not worry about distinguishing between different kinds of HEIF files.
Sounds good - will update code
Just a note here: HEIC/HEIF images from Samsung phones appear to work but images are rotated incorrectly on import.
I can do more diagnostic stuff to see if rotation data is misinterpreted or simply ignored if that would help.
From https://forum.inaturalist.org/t/support-heic-heif-images/17549 Depends on https://github.com/inaturalist/inaturalist/issues/2858, I believe.
Some devices (and now some cameras) save photos in HEIF format, can support for this format be added to the Android app?