expo-image-manipulator 12.0.0 → 12.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/imagemanipulator/FileUtils.kt +6 -0
- package/android/src/main/java/expo/modules/imagemanipulator/ManipulationArguments.kt +11 -4
- package/build/ExpoImageManipulator.web.d.ts.map +1 -1
- package/build/ExpoImageManipulator.web.js.map +1 -1
- package/build/ImageManipulator.js.map +1 -1
- package/build/ImageManipulator.types.d.ts +0 -3
- package/build/ImageManipulator.types.d.ts.map +1 -1
- package/build/ImageManipulator.types.js +0 -3
- package/build/ImageManipulator.types.js.map +1 -1
- package/build/actions/CropAction.web.d.ts +1 -1
- package/build/actions/CropAction.web.js.map +1 -1
- package/build/actions/ExtentAction.web.d.ts +1 -1
- package/build/actions/ExtentAction.web.js.map +1 -1
- package/build/actions/FlipAction.web.d.ts +1 -1
- package/build/actions/ResizeAction.web.d.ts +1 -1
- package/build/actions/ResizeAction.web.js.map +1 -1
- package/build/actions/RotateAction.web.d.ts +1 -1
- package/build/actions/RotateAction.web.js.map +1 -1
- package/build/utils/getContext.web.js.map +1 -1
- package/build/validators.js.map +1 -1
- package/ios/ExpoImageManipulator.podspec +1 -0
- package/ios/ImageManipulatorArguments.swift +3 -0
- package/ios/ImageManipulatorModule.swift +3 -0
- package/package.json +2 -2
- package/src/ImageManipulator.types.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 12.0.2 — 2024-04-23
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 12.0.1 — 2024-04-22
|
|
18
|
+
|
|
19
|
+
### 🎉 New features
|
|
20
|
+
|
|
21
|
+
- Added support for converting to WEBP on Android and iOS. ([#26379](https://github.com/expo/expo/pull/26379) by [@NikitaDudin](https://github.com/NikitaDudin))
|
|
22
|
+
|
|
13
23
|
## 12.0.0 — 2024-04-18
|
|
14
24
|
|
|
15
25
|
### 💡 Others
|
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
group = 'host.exp.exponent'
|
|
4
|
-
version = '12.0.
|
|
4
|
+
version = '12.0.2'
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -14,7 +14,7 @@ android {
|
|
|
14
14
|
namespace "expo.modules.imagemanipulator"
|
|
15
15
|
defaultConfig {
|
|
16
16
|
versionCode 23
|
|
17
|
-
versionName "12.0.
|
|
17
|
+
versionName "12.0.2"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -2,6 +2,7 @@ package expo.modules.imagemanipulator
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.graphics.Bitmap.CompressFormat
|
|
5
|
+
import android.os.Build
|
|
5
6
|
import java.io.File
|
|
6
7
|
import java.io.IOException
|
|
7
8
|
import java.util.*
|
|
@@ -26,6 +27,11 @@ internal object FileUtils {
|
|
|
26
27
|
return when (compressFormat) {
|
|
27
28
|
CompressFormat.JPEG -> ".jpg"
|
|
28
29
|
CompressFormat.PNG -> ".png"
|
|
30
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
31
|
+
CompressFormat.WEBP_LOSSY
|
|
32
|
+
} else {
|
|
33
|
+
CompressFormat.WEBP
|
|
34
|
+
} -> ".webp"
|
|
29
35
|
else -> ".jpg"
|
|
30
36
|
}
|
|
31
37
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package expo.modules.imagemanipulator
|
|
2
2
|
|
|
3
|
-
import android.graphics.Bitmap
|
|
3
|
+
import android.graphics.Bitmap.CompressFormat
|
|
4
|
+
import android.os.Build
|
|
4
5
|
import expo.modules.kotlin.records.Field
|
|
5
6
|
import expo.modules.kotlin.records.Record
|
|
6
7
|
import expo.modules.kotlin.types.Enumerable
|
|
@@ -17,15 +18,21 @@ data class SaveOptions(
|
|
|
17
18
|
) : Record {
|
|
18
19
|
val compressFormat
|
|
19
20
|
get() = when (format) {
|
|
20
|
-
ImageFormat.JPEG, ImageFormat.JPG ->
|
|
21
|
-
ImageFormat.PNG ->
|
|
21
|
+
ImageFormat.JPEG, ImageFormat.JPG -> CompressFormat.JPEG
|
|
22
|
+
ImageFormat.PNG -> CompressFormat.PNG
|
|
23
|
+
ImageFormat.WEBP -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
24
|
+
CompressFormat.WEBP_LOSSY
|
|
25
|
+
} else {
|
|
26
|
+
CompressFormat.WEBP
|
|
27
|
+
}
|
|
22
28
|
}
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
enum class ImageFormat(val value: String) : Enumerable {
|
|
26
32
|
JPEG("jpeg"),
|
|
27
33
|
JPG("jpg"),
|
|
28
|
-
PNG("png")
|
|
34
|
+
PNG("png"),
|
|
35
|
+
WEBP("webp")
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
data class ManipulateAction(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoImageManipulator.web.d.ts","sourceRoot":"","sources":["../src/ExpoImageManipulator.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;;yBA8CnE,MAAM,
|
|
1
|
+
{"version":3,"file":"ExpoImageManipulator.web.d.ts","sourceRoot":"","sources":["../src/ExpoImageManipulator.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;;yBA8CnE,MAAM,0CAEF,WAAW,GACnB,QAAQ,WAAW,CAAC;;AALzB,wBA0BE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoImageManipulator.web.js","sourceRoot":"","sources":["../src/ExpoImageManipulator.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,SAAS,UAAU,CAAC,MAAyB,EAAE,OAAqB;IAClE,IAAI,GAAW,CAAC;IAChB,IAAI,OAAO,EAAE
|
|
1
|
+
{"version":3,"file":"ExpoImageManipulator.web.js","sourceRoot":"","sources":["../src/ExpoImageManipulator.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,SAAS,UAAU,CAAC,MAAyB,EAAE,OAAqB;IAClE,IAAI,GAAW,CAAC;IAChB,IAAI,OAAO,EAAE;QACX,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;QACnC,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC9D,OAAO,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;SAC5D;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC;QAChE,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;KACpD;SAAM;QACL,+BAA+B;QAC/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,MAAM,EAAE,EAAE;YACrD,IAAI,MAAM,IAAI,MAAM,EAAE;gBACpB,OAAO,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;aAClC;iBAAM,IAAI,QAAQ,IAAI,MAAM,EAAE;gBAC7B,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;aACtC;iBAAM,IAAI,QAAQ,IAAI,MAAM,EAAE;gBAC7B,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;aACtC;iBAAM,IAAI,MAAM,IAAI,MAAM,EAAE;gBAC3B,OAAO,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;aAClC;iBAAM,IAAI,QAAQ,IAAI,MAAM,EAAE;gBAC7B,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;aACtC;iBAAM;gBACL,OAAO,MAAM,CAAC;aACf;QACH,CAAC,EAAE,cAAc,CAAC,CAAC;QAEnB,OAAO,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;CACF,CAAC","sourcesContent":["import { ImageResult, SaveOptions, Action } from './ImageManipulator.types';\nimport { crop, extent, flip, resize, rotate } from './actions/index.web';\nimport { getContext } from './utils/getContext.web';\n\nfunction getResults(canvas: HTMLCanvasElement, options?: SaveOptions): ImageResult {\n let uri: string;\n if (options) {\n const { format = 'png' } = options;\n if (options.format === 'png' && options.compress !== undefined) {\n console.warn('compress is not supported with png format.');\n }\n const quality = Math.min(1, Math.max(0, options.compress ?? 1));\n uri = canvas.toDataURL('image/' + format, quality);\n } else {\n // defaults to PNG with no loss\n uri = canvas.toDataURL();\n }\n return {\n uri,\n width: canvas.width,\n height: canvas.height,\n base64: uri.replace(/^data:image\\/\\w+;base64,/, ''),\n };\n}\n\nfunction loadImageAsync(uri: string): Promise<HTMLCanvasElement> {\n return new Promise((resolve, reject) => {\n const imageSource = new Image();\n imageSource.crossOrigin = 'anonymous';\n const canvas = document.createElement('canvas');\n imageSource.onload = () => {\n canvas.width = imageSource.naturalWidth;\n canvas.height = imageSource.naturalHeight;\n\n const context = getContext(canvas);\n context.drawImage(imageSource, 0, 0, imageSource.naturalWidth, imageSource.naturalHeight);\n\n resolve(canvas);\n };\n imageSource.onerror = () => reject(canvas);\n imageSource.src = uri;\n });\n}\n\nexport default {\n async manipulateAsync(\n uri: string,\n actions: Action[] = [],\n options: SaveOptions\n ): Promise<ImageResult> {\n const originalCanvas = await loadImageAsync(uri);\n\n const resultCanvas = actions.reduce((canvas, action) => {\n if ('crop' in action) {\n return crop(canvas, action.crop);\n } else if ('extent' in action) {\n return extent(canvas, action.extent);\n } else if ('resize' in action) {\n return resize(canvas, action.resize);\n } else if ('flip' in action) {\n return flip(canvas, action.flip);\n } else if ('rotate' in action) {\n return rotate(canvas, action.rotate);\n } else {\n return canvas;\n }\n }, originalCanvas);\n\n return getResults(resultCanvas, options);\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageManipulator.js","sourceRoot":"","sources":["../src/ImageManipulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAuB,UAAU,EAAe,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc;AACd;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAW,EACX,UAAoB,EAAE,EACtB,cAA2B,EAAE;IAE7B,IAAI,CAAC,oBAAoB,CAAC,eAAe,EAAE
|
|
1
|
+
{"version":3,"file":"ImageManipulator.js","sourceRoot":"","sources":["../src/ImageManipulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAuB,UAAU,EAAe,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc;AACd;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAW,EACX,UAAoB,EAAE,EACtB,cAA2B,EAAE;IAE7B,IAAI,CAAC,oBAAoB,CAAC,eAAe,EAAE;QACzC,MAAM,IAAI,mBAAmB,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC;KACtE;IAED,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAE7C,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,CAAC;IAC1D,OAAO,MAAM,oBAAoB,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AACvF,CAAC;AAED,cAAc,0BAA0B,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport ExpoImageManipulator from './ExpoImageManipulator';\nimport { Action, ImageResult, SaveFormat, SaveOptions } from './ImageManipulator.types';\nimport { validateArguments } from './validators';\n\n// @needsAudit\n/**\n * Manipulate the image provided via `uri`. Available modifications are rotating, flipping (mirroring),\n * resizing and cropping. Each invocation results in a new file. With one invocation you can provide\n * a set of actions to perform over the image. Overwriting the source file would not have an effect\n * in displaying the result as images are cached.\n * @param uri URI of the file to manipulate. Should be on the local file system or a base64 data URI.\n * @param actions An array of objects representing manipulation options. Each object should have\n * __only one__ of the keys that corresponds to specific transformation.\n * @param saveOptions A map defining how modified image should be saved.\n * @return Promise which fulfils with [`ImageResult`](#imageresult) object.\n */\nexport async function manipulateAsync(\n uri: string,\n actions: Action[] = [],\n saveOptions: SaveOptions = {}\n): Promise<ImageResult> {\n if (!ExpoImageManipulator.manipulateAsync) {\n throw new UnavailabilityError('ImageManipulator', 'manipulateAsync');\n }\n\n validateArguments(uri, actions, saveOptions);\n\n const { format = SaveFormat.JPEG, ...rest } = saveOptions;\n return await ExpoImageManipulator.manipulateAsync(uri, actions, { format, ...rest });\n}\n\nexport * from './ImageManipulator.types';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageManipulator.types.d.ts","sourceRoot":"","sources":["../src/ImageManipulator.types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,MAAM,EAAE;QACN,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,oBAAY,QAAQ;IAClB,QAAQ,aAAa;IACrB,UAAU,eAAe;CAC1B;AAGD,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAGF,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG;IACzB;;;;;OAKG;IACH,MAAM,EAAE;QACN,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAChC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CAAC;AAG1F,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX
|
|
1
|
+
{"version":3,"file":"ImageManipulator.types.d.ts","sourceRoot":"","sources":["../src/ImageManipulator.types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,MAAM,EAAE;QACN,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,oBAAY,QAAQ;IAClB,QAAQ,aAAa;IACrB,UAAU,eAAe;CAC1B;AAGD,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAGF,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG;IACzB;;;;;OAKG;IACH,MAAM,EAAE;QACN,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAChC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CAAC;AAG1F,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAGD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC"}
|
|
@@ -9,9 +9,6 @@ export var SaveFormat;
|
|
|
9
9
|
(function (SaveFormat) {
|
|
10
10
|
SaveFormat["JPEG"] = "jpeg";
|
|
11
11
|
SaveFormat["PNG"] = "png";
|
|
12
|
-
/**
|
|
13
|
-
* @platform web
|
|
14
|
-
*/
|
|
15
12
|
SaveFormat["WEBP"] = "webp";
|
|
16
13
|
})(SaveFormat || (SaveFormat = {}));
|
|
17
14
|
//# sourceMappingURL=ImageManipulator.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageManipulator.types.js","sourceRoot":"","sources":["../src/ImageManipulator.types.ts"],"names":[],"mappings":"AA4CA,eAAe;AACf,MAAM,CAAN,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,iCAAqB,CAAA;IACrB,qCAAyB,CAAA;AAC3B,CAAC,EAHW,QAAQ,KAAR,QAAQ,QAGnB;AA4CD,eAAe;AACf,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"ImageManipulator.types.js","sourceRoot":"","sources":["../src/ImageManipulator.types.ts"],"names":[],"mappings":"AA4CA,eAAe;AACf,MAAM,CAAN,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,iCAAqB,CAAA;IACrB,qCAAyB,CAAA;AAC3B,CAAC,EAHW,QAAQ,KAAR,QAAQ,QAGnB;AA4CD,eAAe;AACf,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,2BAAa,CAAA;AACf,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB","sourcesContent":["// @needsAudit\nexport type ImageResult = {\n /**\n * An URI to the modified image (usable as the source for an `Image` or `Video` element).\n */\n uri: string;\n /**\n * Width of the image or video.\n */\n width: number;\n /**\n * Height of the image or video.\n */\n height: number;\n /**\n * It is included if the `base64` save option was truthy, and is a string containing the\n * JPEG/PNG (depending on `format`) data of the image in Base64. Prepend that with `'data:image/xxx;base64,'`\n * to get a data URI, which you can use as the source for an `Image` element for example\n * (where `xxx` is `jpeg` or `png`).\n */\n base64?: string;\n};\n\n// @needsAudit\nexport type ActionResize = {\n /**\n * Values correspond to the result image dimensions. If you specify only one value, the other will\n * be calculated automatically to preserve image ratio.\n */\n resize: {\n width?: number;\n height?: number;\n };\n};\n\n// @needsAudit\nexport type ActionRotate = {\n /**\n * Degrees to rotate the image. Rotation is clockwise when the value is positive and\n * counter-clockwise when negative.\n */\n rotate: number;\n};\n\n// @docsMissing\nexport enum FlipType {\n Vertical = 'vertical',\n Horizontal = 'horizontal',\n}\n\n// @needsAudit\nexport type ActionFlip = {\n /**\n * An axis on which image will be flipped. Only one flip per transformation is available. If you\n * want to flip according to both axes then provide two separate transformations.\n */\n flip: FlipType;\n};\n\n// @needsAudit\nexport type ActionCrop = {\n /**\n * Fields specify top-left corner and dimensions of a crop rectangle.\n */\n crop: {\n originX: number;\n originY: number;\n width: number;\n height: number;\n };\n};\n\n// @needsAudit\nexport type ActionExtent = {\n /**\n * Set the image size and offset. If the image is enlarged, unfilled areas are set to the `backgroundColor`.\n * To position the image, use `originX` and `originY`.\n *\n * @platform web\n */\n extent: {\n backgroundColor?: string | null;\n originX?: number;\n originY?: number;\n width: number;\n height: number;\n };\n};\n\n// @docsMissing\nexport type Action = ActionResize | ActionRotate | ActionFlip | ActionCrop | ActionExtent;\n\n// @docsMissing\nexport enum SaveFormat {\n JPEG = 'jpeg',\n PNG = 'png',\n WEBP = 'webp',\n}\n\n// @needsAudit\n/**\n * A map defining how modified image should be saved.\n */\nexport type SaveOptions = {\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64?: boolean;\n /**\n * A value in range `0.0` - `1.0` specifying compression level of the result image. `1` means\n * no compression (highest quality) and `0` the highest compression (lowest quality).\n */\n compress?: number;\n /**\n * Specifies what type of compression should be used and what is the result file extension.\n * `SaveFormat.PNG` compression is lossless but slower, `SaveFormat.JPEG` is faster but the image\n * has visible artifacts. Defaults to `SaveFormat.JPEG`\n */\n format?: SaveFormat;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ActionCrop } from '../ImageManipulator.types';
|
|
2
|
-
declare const _default: (canvas: HTMLCanvasElement, options: ActionCrop[
|
|
2
|
+
declare const _default: (canvas: HTMLCanvasElement, options: ActionCrop['crop']) => HTMLCanvasElement;
|
|
3
3
|
export default _default;
|
|
4
4
|
//# sourceMappingURL=CropAction.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CropAction.web.js","sourceRoot":"","sources":["../../src/actions/CropAction.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,eAAe,CAAC,MAAyB,EAAE,OAA2B,EAAE,EAAE;IACxE,6BAA6B;IAC7B,IAAI,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GA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CAAC,CAAC;IAEhF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { CodedError } from 'expo-modules-core';\n\nimport { ActionCrop } from '../ImageManipulator.types';\nimport { getContext } from '../utils/getContext.web';\n\nexport default (canvas: HTMLCanvasElement, options: ActionCrop['crop']) => {\n // ensure values are defined.\n let { originX = 0, originY = 0, width = 0, height = 0 } = options;\n const clamp = (value, max) => Math.max(0, Math.min(max, value));\n // lock within bounds.\n width = clamp(width, canvas.width);\n height = clamp(height, canvas.height);\n originX = clamp(originX, canvas.width);\n originY = clamp(originY, canvas.height);\n\n // lock sum of crop.\n width = Math.min(originX + width, canvas.width) - originX;\n height = Math.min(originY + height, canvas.height) - originY;\n\n if (width === 0 || height === 0) {\n throw new CodedError(\n 'ERR_IMAGE_MANIPULATOR_CROP',\n 'Crop size must be greater than 0: ' + JSON.stringify(options, null, 2)\n );\n }\n\n const result = document.createElement('canvas');\n result.width = width;\n result.height = height;\n\n const context = getContext(result);\n context.drawImage(canvas, originX, originY, width, height, 0, 0, width, height);\n\n return result;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ActionExtent } from '../ImageManipulator.types';
|
|
2
|
-
declare const _default: (canvas: HTMLCanvasElement, options: ActionExtent[
|
|
2
|
+
declare const _default: (canvas: HTMLCanvasElement, options: ActionExtent['extent']) => HTMLCanvasElement;
|
|
3
3
|
export default _default;
|
|
4
4
|
//# sourceMappingURL=ExtentAction.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtentAction.web.js","sourceRoot":"","sources":["../../src/actions/ExtentAction.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,eAAe,CAAC,MAAyB,EAAE,OAA+B,EAAE,EAAE;IAC5E,6BAA6B;IAC7B,MAAM,EAAE,eAAe,GAAG,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,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC,CAAC;IAClG,MAAM,EAAE,GACN,OAAO,GAAG,CAAC;QACT,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAC3C,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC;IAEhD,MAAM,EAAE,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,EAAE,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IAEnC,IAAI,eAAe,IAAI,IAAI,EAAE;QAC3B,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC;QACpC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;KACvC;IAED,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAE1D,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { CodedError } from 'expo-modules-core';\n\nimport { ActionExtent } from '../ImageManipulator.types';\nimport { getContext } from '../utils/getContext.web';\n\nexport default (canvas: HTMLCanvasElement, options: ActionExtent['extent']) => {\n // ensure values are defined.\n const { backgroundColor = null, originX = 0, originY = 0, width = 0, height = 0 } = options;\n\n if (width === 0 || height === 0) {\n throw new CodedError(\n 'ERR_IMAGE_MANIPULATOR_EXTENT',\n 'Extent size must be greater than 0: ' + JSON.stringify(options, null, 2)\n );\n }\n\n const result = document.createElement('canvas');\n result.width = width;\n result.height = height;\n\n const sx = originX < 0 ? 0 : originX;\n const sy = originY < 0 ? 0 : originY;\n const sw =\n originX < 0 ? Math.min(canvas.width, width + originX) : Math.min(canvas.width - originX, width);\n const sh =\n originY < 0\n ? Math.min(canvas.height, height + originY)\n : Math.min(canvas.height - originY, height);\n\n const dx = originX < 0 ? -originX : 0;\n const dy = originY < 0 ? -originY : 0;\n\n const context = getContext(result);\n\n if (backgroundColor != null) {\n context.fillStyle = backgroundColor;\n context.fillRect(0, 0, width, height);\n }\n\n context.drawImage(canvas, sx, sy, sw, sh, dx, dy, sw, sh);\n\n return result;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ActionFlip } from '../ImageManipulator.types';
|
|
2
|
-
declare const _default: (canvas: HTMLCanvasElement, flip: ActionFlip[
|
|
2
|
+
declare const _default: (canvas: HTMLCanvasElement, flip: ActionFlip['flip']) => HTMLCanvasElement;
|
|
3
3
|
export default _default;
|
|
4
4
|
//# sourceMappingURL=FlipAction.web.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ActionResize } from '../ImageManipulator.types';
|
|
2
|
-
declare const _default: (canvas: HTMLCanvasElement, { width, height }: ActionResize[
|
|
2
|
+
declare const _default: (canvas: HTMLCanvasElement, { width, height }: ActionResize['resize']) => HTMLCanvasElement;
|
|
3
3
|
export default _default;
|
|
4
4
|
//# sourceMappingURL=ResizeAction.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResizeAction.web.js","sourceRoot":"","sources":["../../src/actions/ResizeAction.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD;;;;;;;;GAQG;AACH,SAAS,cAAc,CACrB,MAAyB,EACzB,KAAa,EACb,MAAc,EACd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AC/B,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,YAAY,CAAC;SACrC;KACF;IAED,eAAe;IACf,IAAI,YAAY,EAAE;QAChB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;KACxB;IAED,MAAM;IACN,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAEjC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,eAAe,CAAC,MAAyB,EAAE,EAAE,KAAK,EAAE,MAAM,EAA0B,EAAE,EAAE;IACtF,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAEhD,IAAI,cAAc,GAAW,CAAC,CAAC;IAC/B,IAAI,eAAe,GAAW,CAAC,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,cAAc,GAAG,KAAK,CAAC;QACvB,eAAe,GAAG,cAAc,GAAG,UAAU,CAAC;KAC/C;IACD,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,eAAe,GAAG,MAAM,CAAC;QACzB,IAAI,cAAc,KAAK,CAAC,EAAE;YACxB,cAAc,GAAG,eAAe,GAAG,UAAU,CAAC;SAC/C;KACF;IAED,OAAO,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;AACvE,CAAC,CAAC","sourcesContent":["import { ActionResize } from '../ImageManipulator.types';\nimport { getContext } from '../utils/getContext.web';\n\n/**\n * Hermite resize - fast image resize/resample using Hermite filter. 1 cpu version!\n * https://stackoverflow.com/a/18320662/4047926\n *\n * @param {HTMLCanvasElement} canvas\n * @param {int} width\n * @param {int} height\n * @param {boolean} resizeCanvas if true, canvas will be resized. Optional.\n */\nfunction resampleSingle(\n canvas: HTMLCanvasElement,\n width: number,\n height: number,\n resizeCanvas: boolean = false\n): HTMLCanvasElement {\n const result = document.createElement('canvas');\n result.width = canvas.width;\n result.height = canvas.height;\n\n const widthSource = canvas.width;\n const heightSource = canvas.height;\n width = Math.round(width);\n height = Math.round(height);\n\n const wRatio = widthSource / width;\n const hRatio = heightSource / height;\n const wRatioHalf = Math.ceil(wRatio / 2);\n const hRatioHalf = Math.ceil(hRatio / 2);\n\n const ctx = getContext(canvas);\n\n const img = ctx.getImageData(0, 0, widthSource, heightSource);\n const img2 = ctx.createImageData(width, height);\n const data = img.data;\n const data2 = img2.data;\n\n for (let j = 0; j < height; j++) {\n for (let i = 0; i < width; i++) {\n const x2 = (i + j * width) * 4;\n let weight = 0;\n let weights = 0;\n let weightsAlpha = 0;\n let gx_r = 0;\n let gx_g = 0;\n let gx_b = 0;\n let gx_a = 0;\n const yCenter = (j + 0.5) * hRatio;\n const yy_start = Math.floor(j * hRatio);\n const yy_stop = Math.ceil((j + 1) * hRatio);\n for (let yy = yy_start; yy < yy_stop; yy++) {\n const dy = Math.abs(yCenter - (yy + 0.5)) / hRatioHalf;\n const center_x = (i + 0.5) * wRatio;\n const w0 = dy * dy; //pre-calc part of w\n const xx_start = Math.floor(i * wRatio);\n const xx_stop = Math.ceil((i + 1) * wRatio);\n for (let xx = xx_start; xx < xx_stop; xx++) {\n const dx = Math.abs(center_x - (xx + 0.5)) / wRatioHalf;\n const w = Math.sqrt(w0 + dx * dx);\n if (w >= 1) {\n //pixel too far\n continue;\n }\n //hermite filter\n weight = 2 * w * w * w - 3 * w * w + 1;\n const xPosition = 4 * (xx + yy * widthSource);\n //alpha\n gx_a += weight * data[xPosition + 3];\n weightsAlpha += weight;\n //colors\n if (data[xPosition + 3] < 255) {\n weight = (weight * data[xPosition + 3]) / 250;\n }\n gx_r += weight * data[xPosition];\n gx_g += weight * data[xPosition + 1];\n gx_b += weight * data[xPosition + 2];\n weights += weight;\n }\n }\n data2[x2] = gx_r / weights;\n data2[x2 + 1] = gx_g / weights;\n data2[x2 + 2] = gx_b / weights;\n data2[x2 + 3] = gx_a / weightsAlpha;\n }\n }\n\n //resize canvas\n if (resizeCanvas) {\n result.width = width;\n result.height = height;\n }\n\n //draw\n const context = getContext(result);\n context.putImageData(img2, 0, 0);\n\n return result;\n}\n\nexport default (canvas: HTMLCanvasElement, { width, height }: ActionResize['resize']) => {\n const imageRatio = canvas.width / canvas.height;\n\n let requestedWidth: number = 0;\n let requestedHeight: number = 0;\n if (width !== undefined) {\n requestedWidth = width;\n requestedHeight = requestedWidth / imageRatio;\n }\n if (height !== undefined) {\n requestedHeight = height;\n if (requestedWidth === 0) {\n requestedWidth = requestedHeight * imageRatio;\n }\n }\n\n return resampleSingle(canvas, requestedWidth, requestedHeight, true);\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ActionRotate } from '../ImageManipulator.types';
|
|
2
|
-
declare const _default: (canvas: HTMLCanvasElement, degrees: ActionRotate[
|
|
2
|
+
declare const _default: (canvas: HTMLCanvasElement, degrees: ActionRotate['rotate']) => HTMLCanvasElement;
|
|
3
3
|
export default _default;
|
|
4
4
|
//# sourceMappingURL=RotateAction.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RotateAction.web.js","sourceRoot":"","sources":["../../src/actions/RotateAction.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,SAAS,aAAa,CACpB,KAAa,EACb,MAAc,EACd,KAAa;IAEb,MAAM,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IACxC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1B,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1B,IAAI,CAAC,GAAG,CAAC,EAAE
|
|
1
|
+
{"version":3,"file":"RotateAction.web.js","sour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,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAC1C,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAExB,iBAAiB;IACjB,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAE9F,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { ActionRotate } from '../ImageManipulator.types';\nimport { getContext } from '../utils/getContext.web';\n\nfunction sizeFromAngle(\n width: number,\n height: number,\n angle: number\n): { width: number; height: number } {\n const radians = (angle * Math.PI) / 180;\n let c = Math.cos(radians);\n let s = Math.sin(radians);\n if (s < 0) {\n s = -s;\n }\n if (c < 0) {\n c = -c;\n }\n return { width: height * s + width * c, height: height * c + width * s };\n}\n\nexport default (canvas: HTMLCanvasElement, degrees: ActionRotate['rotate']) => {\n const { width, height } = sizeFromAngle(canvas.width, canvas.height, degrees);\n\n const result = document.createElement('canvas');\n result.width = width;\n result.height = height;\n\n const context = getContext(result);\n\n // Set the origin to the center of the image\n context.translate(result.width / 2, result.height / 2);\n\n // Rotate the canvas around the origin\n const radians = (degrees * Math.PI) / 180;\n context.rotate(radians);\n\n // Draw the image\n context.drawImage(canvas, -canvas.width / 2, -canvas.height / 2, canvas.width, canvas.height);\n\n return result;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getContext.web.js","sourceRoot":"","sources":["../../src/utils/getContext.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,UAAU,UAAU,CAAC,MAAyB;IAClD,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,GAAG,EAAE
|
|
1
|
+
{"version":3,"file":"getContext.web.js","sourceRoot":"","sources":["../../src/utils/getContext.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,UAAU,UAAU,CAAC,MAAyB;IAClD,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,UAAU,CAAC,uBAAuB,EAAE,iCAAiC,CAAC,CAAC;KAClF;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { CodedError } from 'expo-modules-core';\n\nexport function getContext(canvas: HTMLCanvasElement): CanvasRenderingContext2D {\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n throw new CodedError('ERR_IMAGE_MANIPULATOR', 'Failed to create canvas context');\n }\n return ctx;\n}\n"]}
|
package/build/validators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,QAAQ,EACR,UAAU,GAEX,MAAM,0BAA0B,CAAC;AAElC,MAAM,UAAU,iBAAiB,CAAC,GAAW,EAAE,OAAiB,EAAE,WAAwB;IACxF,WAAW,CAAC,GAAG,CAAC,CAAC;IACjB,eAAe,CAAC,OAAO,CAAC,CAAC;IACzB,mBAAmB,CAAC,WAAW,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,IAAI,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,EAAE
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,QAAQ,EACR,UAAU,GAEX,MAAM,0BAA0B,CAAC;AAElC,MAAM,UAAU,iBAAiB,CAAC,GAAW,EAAE,OAAiB,EAAE,WAAwB;IACxF,WAAW,CAAC,GAAG,CA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AK,SAAS,IAAI,OAAO,MAAM,KAAK,SAAS,EAAE;QACvD,MAAM,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;KAChE;IACD,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,MAAM,IAAI,SAAS,CAAC,0CAA0C,CAAC,CAAC;SACjE;QACD,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE;YAChC,MAAM,IAAI,SAAS,CAAC,0DAA0D,CAAC,CAAC;SACjF;KACF;IACD,MAAM,cAAc,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAC1E,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC5D,MAAM,IAAI,SAAS,CAAC,yCAAyC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KAC3F;AACH,CAAC","sourcesContent":["import {\n Action,\n ActionCrop,\n ActionExtent,\n ActionFlip,\n ActionResize,\n ActionRotate,\n FlipType,\n SaveFormat,\n SaveOptions,\n} from './ImageManipulator.types';\n\nexport function validateArguments(uri: string, actions: Action[], saveOptions: SaveOptions) {\n validateUri(uri);\n validateActions(actions);\n validateSaveOptions(saveOptions);\n}\n\nexport function validateUri(uri: string): void {\n if (!(typeof uri === 'string')) {\n throw new TypeError('The \"uri\" argument must be a string');\n }\n}\n\nexport function validateActions(actions: Action[]): void {\n if (!Array.isArray(actions)) {\n throw new TypeError('The \"actions\" argument must be an array');\n }\n for (const action of actions) {\n if (typeof action !== 'object' || action === null) {\n throw new TypeError('Action must be an object');\n }\n const supportedActionTypes = ['crop', 'extent', 'flip', 'rotate', 'resize'];\n const actionKeys = Object.keys(action);\n if (actionKeys.length !== 1) {\n throw new TypeError(\n `Single action must contain exactly one transformation: ${supportedActionTypes.join(', ')}`\n );\n }\n const actionType = actionKeys[0];\n if (!supportedActionTypes.includes(actionType)) {\n throw new TypeError(`Unsupported action type: ${actionType}`);\n }\n\n if (actionType === 'crop') {\n validateCropAction(action as ActionCrop);\n } else if (actionType === 'extent') {\n validateExtentAction(action as ActionExtent);\n } else if (actionType === 'flip') {\n validateFlipAction(action as ActionFlip);\n } else if (actionType === 'rotate') {\n validateRotateAction(action as ActionRotate);\n } else if (actionType === 'resize') {\n validateResizeAction(action as ActionResize);\n }\n }\n}\n\nfunction validateCropAction(action: ActionCrop): void {\n const isValid =\n typeof action.crop === 'object' &&\n action.crop !== null &&\n typeof action.crop.originX === 'number' &&\n typeof action.crop.originY === 'number' &&\n typeof action.crop.width === 'number' &&\n typeof action.crop.height === 'number';\n if (!isValid) {\n throw new TypeError(\n 'Crop action must be an object of shape { originX: number; originY: number; width: number; height: number }'\n );\n }\n}\n\nfunction validateExtentAction(action: ActionExtent): void {\n const isValid =\n typeof action.extent === 'object' &&\n action.extent !== null &&\n (action.extent.backgroundColor == null || typeof action.extent.backgroundColor === 'string') &&\n (action.extent.originX == null || typeof action.extent.originX === 'number') &&\n (action.extent.originY == null || typeof action.extent.originY === 'number') &&\n typeof action.extent.width === 'number' &&\n typeof action.extent.height === 'number';\n if (!isValid) {\n throw new TypeError(\n 'Extent action must be an object of shape { backgroundColor?: string; originX?: number; originY?: number; width: number; height: number }'\n );\n }\n}\n\nfunction validateFlipAction(action: ActionFlip): void {\n if (\n typeof action.flip !== 'string' ||\n ![FlipType.Horizontal, FlipType.Vertical].includes(action.flip)\n ) {\n throw new TypeError(`Unsupported flip type: ${action.flip}`);\n }\n}\n\nfunction validateRotateAction(action: ActionRotate): void {\n if (typeof action.rotate !== 'number') {\n throw new TypeError('Rotation must be a number');\n }\n}\n\nfunction validateResizeAction(action: ActionResize): void {\n const isValid =\n typeof action.resize === 'object' &&\n action.resize !== null &&\n (typeof action.resize.width === 'number' || typeof action.resize.width === 'undefined') &&\n (typeof action.resize.height === 'number' || typeof action.resize.height === 'undefined');\n if (!isValid) {\n throw new TypeError(\n 'Resize action must be an object of shape { width?: number; height?: number }'\n );\n }\n}\n\nexport function validateSaveOptions({ base64, compress, format }: SaveOptions): void {\n if (base64 !== undefined && typeof base64 !== 'boolean') {\n throw new TypeError('The \"base64\" argument must be a boolean');\n }\n if (compress !== undefined) {\n if (typeof compress !== 'number') {\n throw new TypeError('The \"compress\" argument must be a number');\n }\n if (compress < 0 || compress > 1) {\n throw new TypeError('The \"compress\" argument must be a number between 0 and 1');\n }\n }\n const allowedFormats = [SaveFormat.JPEG, SaveFormat.PNG, SaveFormat.WEBP];\n if (format !== undefined && !allowedFormats.includes(format)) {\n throw new TypeError(`The \"format\" argument must be one of: ${allowedFormats.join(', ')}`);\n }\n}\n"]}
|
|
@@ -81,6 +81,7 @@ internal enum ImageFormat: String, EnumArgument {
|
|
|
81
81
|
case jpeg
|
|
82
82
|
case jpg
|
|
83
83
|
case png
|
|
84
|
+
case webp
|
|
84
85
|
|
|
85
86
|
var fileExtension: String {
|
|
86
87
|
switch self {
|
|
@@ -88,6 +89,8 @@ internal enum ImageFormat: String, EnumArgument {
|
|
|
88
89
|
return ".jpg"
|
|
89
90
|
case .png:
|
|
90
91
|
return ".png"
|
|
92
|
+
case .webp:
|
|
93
|
+
return ".webp"
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
}
|
|
@@ -4,6 +4,7 @@ import CoreGraphics
|
|
|
4
4
|
import Photos
|
|
5
5
|
import UIKit
|
|
6
6
|
import ExpoModulesCore
|
|
7
|
+
import SDWebImageWebPCoder
|
|
7
8
|
|
|
8
9
|
public class ImageManipulatorModule: Module {
|
|
9
10
|
typealias LoadImageCallback = (Result<UIImage, Error>) -> Void
|
|
@@ -128,5 +129,7 @@ func imageData(from image: UIImage, format: ImageFormat, compression: Double) ->
|
|
|
128
129
|
return image.jpegData(compressionQuality: compression)
|
|
129
130
|
case .png:
|
|
130
131
|
return image.pngData()
|
|
132
|
+
case .webp:
|
|
133
|
+
return SDImageWebPCoder.shared.encodedData(with: image, format: .webP, options: [.encodeCompressionQuality: compression])
|
|
131
134
|
}
|
|
132
135
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-image-manipulator",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.2",
|
|
4
4
|
"description": "Provides functions that let you manipulation images on the local file system, eg: resize, crop.",
|
|
5
5
|
"main": "build/ImageManipulator.js",
|
|
6
6
|
"types": "build/ImageManipulator.d.ts",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"expo": "*"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "ee4f30ef3b5fa567ad1bf94794197f7683fdd481"
|
|
43
43
|
}
|