This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo ImageManipulator
一个提供用于在本地文件系统上处理图像的 API 的库。
expo-image-manipulator 提供用于修改本地文件系统中存储的图像的 API。
安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
此操作会先将图像顺时针旋转 90 度,然后垂直翻转旋转后的图像,并将其保存为 PNG。
API
import * as ImageManipulator from 'expo-image-manipulator';
Constants
Type: ImageManipulator
Hooks
Classes
Type: Class extends NativeModule
ImageManipulator Methods
Loads an image from the given URI and creates a new image manipulation context.
ImageManipulatorContextType: Class extends SharedObject
A context for an image manipulation. It provides synchronous, chainable functions that schedule transformations on the original image to the background thread.
Use an asynchronous renderAsync to await for all transformations to finish and access the final image.
ImageManipulatorContext Methods
Set the image size and offset. If the image is enlarged, unfilled areas are set to the backgroundColor.
To position the image, use originX and originY.
ImageManipulatorContextAwaits for all manipulation tasks to finish and resolves with a reference to the resulted native image.
Promise<ImageRef>Resets the manipulator context to the originally loaded image.
ImageManipulatorContextType: Class extends SharedRef<'image'>
A reference to a native instance of the image.
ImageRef Properties
ImageRef Methods
Methods
Deprecated: It has been replaced by the new, contextual and object-oriented API. Use
ImageManipulator.manipulateoruseImageManipulatorinstead.
Manipulate the image provided via uri. Available modifications are rotating, flipping (mirroring),
resizing and cropping. Each invocation results in a new file. With one invocation you can provide
a set of actions to perform over the image. Overwriting the source file would not have an effect
in displaying the result as images are cached.
Promise<ImageResult>Promise which fulfils with ImageResult object.
Types
Literal type: union
Acceptable values are: ActionResize | ActionRotate | ActionFlip | ActionCrop | ActionExtent