to avoid https://issuetracker.google.com/issues/158753935, use androidx.exifinterface:exifinterface:1.2.0
This commit is contained in:
parent
58ae3a9b69
commit
1aa15618c9
|
@ -18,3 +18,4 @@ output.json
|
||||||
/.idea/caches/
|
/.idea/caches/
|
||||||
/.idea/codeStyles/
|
/.idea/codeStyles/
|
||||||
/_Emoji/*
|
/_Emoji/*
|
||||||
|
/app/rc/release/
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
<option value="$PROJECT_DIR$/colorpicker" />
|
<option value="$PROJECT_DIR$/colorpicker" />
|
||||||
<option value="$PROJECT_DIR$/emoji" />
|
<option value="$PROJECT_DIR$/emoji" />
|
||||||
<option value="$PROJECT_DIR$/exif" />
|
|
||||||
<option value="$PROJECT_DIR$/sample_apng" />
|
<option value="$PROJECT_DIR$/sample_apng" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" group="SubwayTooter/app" />
|
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" group="SubwayTooter/app" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/colorpicker/colorpicker.iml" filepath="$PROJECT_DIR$/colorpicker/colorpicker.iml" group="SubwayTooter/colorpicker" />
|
<module fileurl="file://$PROJECT_DIR$/colorpicker/colorpicker.iml" filepath="$PROJECT_DIR$/colorpicker/colorpicker.iml" group="SubwayTooter/colorpicker" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/emoji/emoji.iml" filepath="$PROJECT_DIR$/emoji/emoji.iml" group="SubwayTooter/emoji" />
|
<module fileurl="file://$PROJECT_DIR$/emoji/emoji.iml" filepath="$PROJECT_DIR$/emoji/emoji.iml" group="SubwayTooter/emoji" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/exif/exif.iml" filepath="$PROJECT_DIR$/exif/exif.iml" group="SubwayTooter/exif" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/sample_apng/sample_apng.iml" filepath="$PROJECT_DIR$/sample_apng/sample_apng.iml" group="SubwayTooter/sample_apng" />
|
<module fileurl="file://$PROJECT_DIR$/sample_apng/sample_apng.iml" filepath="$PROJECT_DIR$/sample_apng/sample_apng.iml" group="SubwayTooter/sample_apng" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -91,11 +91,12 @@ dependencies {
|
||||||
exclude group: 'com.android.support', module: 'support-annotations'
|
exclude group: 'com.android.support', module: 'support-annotations'
|
||||||
})
|
})
|
||||||
|
|
||||||
implementation project(':exif')
|
// implementation project(':exif')
|
||||||
implementation project(':colorpicker')
|
implementation project(':colorpicker')
|
||||||
implementation project(':emoji')
|
implementation project(':emoji')
|
||||||
implementation project(':apng_android')
|
implementation project(':apng_android')
|
||||||
|
|
||||||
|
|
||||||
implementation "androidx.appcompat:appcompat:$appcompat_version"
|
implementation "androidx.appcompat:appcompat:$appcompat_version"
|
||||||
|
|
||||||
// DrawerLayout
|
// DrawerLayout
|
||||||
|
@ -107,6 +108,8 @@ dependencies {
|
||||||
// PreferenceManager
|
// PreferenceManager
|
||||||
implementation "androidx.preference:preference-ktx:1.1.1"
|
implementation "androidx.preference:preference-ktx:1.1.1"
|
||||||
|
|
||||||
|
implementation "androidx.exifinterface:exifinterface:1.2.0"
|
||||||
|
|
||||||
// CustomTabs
|
// CustomTabs
|
||||||
implementation "androidx.browser:browser:1.2.0"
|
implementation "androidx.browser:browser:1.2.0"
|
||||||
|
|
||||||
|
|
|
@ -511,7 +511,7 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
|
||||||
@Suppress("SameParameterValue") pixel_max : Int
|
@Suppress("SameParameterValue") pixel_max : Int
|
||||||
) : Pair<Bitmap?, String?> {
|
) : Pair<Bitmap?, String?> {
|
||||||
|
|
||||||
val orientation : Int? = ByteArrayInputStream(data).imageOrientation
|
val orientation : Int? = ByteArrayInputStream(data).imageOrientation()
|
||||||
|
|
||||||
// detects image size
|
// detects image size
|
||||||
options.inJustDecodeBounds = true
|
options.inJustDecodeBounds = true
|
||||||
|
|
|
@ -2,8 +2,9 @@ package jp.juggler.util
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.*
|
import android.graphics.*
|
||||||
|
import androidx.exifinterface.media.ExifInterface
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import it.sephiroth.android.library.exif2.ExifInterface
|
//import it.sephiroth.android.library.exif2.ExifInterface
|
||||||
import java.io.FileNotFoundException
|
import java.io.FileNotFoundException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
@ -11,16 +12,17 @@ import kotlin.math.sqrt
|
||||||
|
|
||||||
private val log = LogCategory("BitmapUtils")
|
private val log = LogCategory("BitmapUtils")
|
||||||
|
|
||||||
val InputStream.imageOrientation : Int?
|
fun InputStream.imageOrientation() : Int? =
|
||||||
get() = try {
|
try {
|
||||||
ExifInterface()
|
ExifInterface(this)
|
||||||
.readExif(
|
// .readExif(
|
||||||
this@imageOrientation,
|
// this@imageOrientation,
|
||||||
ExifInterface.Options.OPTION_IFD_0
|
// ExifInterface.Options.OPTION_IFD_0
|
||||||
or ExifInterface.Options.OPTION_IFD_1
|
// or ExifInterface.Options.OPTION_IFD_1
|
||||||
or ExifInterface.Options.OPTION_IFD_EXIF
|
// or ExifInterface.Options.OPTION_IFD_EXIF
|
||||||
)
|
// )
|
||||||
.getTagIntValue(ExifInterface.TAG_ORIENTATION)
|
.getAttributeInt(ExifInterface.TAG_ORIENTATION, - 1)
|
||||||
|
.takeIf { it >= 0 }
|
||||||
} catch(ex : Throwable) {
|
} catch(ex : Throwable) {
|
||||||
log.w(ex, "imageOrientation: exif parse failed.")
|
log.w(ex, "imageOrientation: exif parse failed.")
|
||||||
null
|
null
|
||||||
|
@ -60,8 +62,10 @@ fun Matrix.resolveOrientation(orientation : Int?) : Matrix {
|
||||||
enum class ResizeType {
|
enum class ResizeType {
|
||||||
// リサイズなし
|
// リサイズなし
|
||||||
None,
|
None,
|
||||||
|
|
||||||
// 長辺がsize以下になるようリサイズ
|
// 長辺がsize以下になるようリサイズ
|
||||||
LongSide,
|
LongSide,
|
||||||
|
|
||||||
// 平方ピクセルが size*size 以下になるようリサイズ
|
// 平方ピクセルが size*size 以下になるようリサイズ
|
||||||
SquarePixel,
|
SquarePixel,
|
||||||
}
|
}
|
||||||
|
@ -104,7 +108,7 @@ fun createResizedBitmap(
|
||||||
try {
|
try {
|
||||||
|
|
||||||
val orientation : Int? = context.contentResolver.openInputStream(uri)?.use {
|
val orientation : Int? = context.contentResolver.openInputStream(uri)?.use {
|
||||||
it.imageOrientation
|
it.imageOrientation()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 画像のサイズを調べる
|
// 画像のサイズを調べる
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
include ':app', ':sample_apng', ':apng_android', ':apng', ':exif', ':colorpicker', ':emoji'
|
include ':app', ':sample_apng', ':apng_android', ':apng', ':colorpicker', ':emoji'
|
||||||
|
|
Loading…
Reference in New Issue