Skip to content

Commit

Permalink
Update image package version to 4.0.6 (chooyan-eng#84)
Browse files Browse the repository at this point in the history
* Bump image version to 4.0.4 + update `_doCrop` and `_doCropCircle` methods accordingly

* Update package version to `0.7.4`

* fix formating

* Change android tool gradle

* Update image to 4.0.6

* format code
  • Loading branch information
ravikant-paudel authored Jan 10, 2023
1 parent 216ebef commit 3baf70f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 21 deletions.
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 30
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -36,7 +36,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 16
targetSdkVersion 30
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
1 change: 1 addition & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
Expand Down
8 changes: 4 additions & 4 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.7.20'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ packages:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.2"
version: "4.0.4"
matcher:
dependency: transitive
description:
Expand Down
24 changes: 14 additions & 10 deletions lib/src/crop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,10 @@ Uint8List _doCrop(List<dynamic> cropData) {
image.encodePng(
image.copyCrop(
originalImage,
rect.left.toInt(),
rect.top.toInt(),
rect.width.toInt(),
rect.height.toInt(),
x: rect.left.toInt(),
y: rect.top.toInt(),
width: rect.width.toInt(),
height: rect.height.toInt(),
),
),
);
Expand All @@ -709,12 +709,16 @@ Uint8List _doCrop(List<dynamic> cropData) {
Uint8List _doCropCircle(List<dynamic> cropData) {
final originalImage = cropData[0] as image.Image;
final rect = cropData[1] as Rect;
final center = image.Point(
rect.left + rect.width / 2,
rect.top + rect.height / 2,
);
return Uint8List.fromList(
image.encodePng(
image.copyCropCircle(
originalImage,
center:
image.Point(rect.left + rect.width / 2, rect.top + rect.height / 2),
centerX: center.xi,
centerY: center.yi,
radius: min(rect.width, rect.height) ~/ 2,
),
),
Expand All @@ -727,13 +731,13 @@ image.Image _fromByteData(Uint8List data) {
assert(tempImage != null);

// check orientation
switch (tempImage?.exif.data[0x0112] ?? -1) {
switch (tempImage?.exif.exifIfd.orientation ?? -1) {
case 3:
return image.copyRotate(tempImage!, 180);
return image.copyRotate(tempImage!, angle: 180);
case 6:
return image.copyRotate(tempImage!, 90);
return image.copyRotate(tempImage!, angle: 90);
case 8:
return image.copyRotate(tempImage!, -90);
return image.copyRotate(tempImage!, angle: -90);
}
return tempImage!;
}
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ packages:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.2"
version: "4.0.4"
matcher:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: crop_your_image
description: crop_your_image helps your app to embed Widgets for cropping images.
version: 0.7.3
version: 0.7.4
homepage: https://github.com/chooyan-eng/crop_your_image

environment:
Expand All @@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
image: ^3.2.2
image: ^4.0.6

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 3baf70f

Please sign in to comment.