expo-image-manipulator
Version:
Provides functions that let you manipulation images on the local file system, eg: resize, crop.
24 lines (22 loc) • 1.08 kB
JavaScript
import { NativeModule, registerWebModule } from 'expo';
import ImageManipulatorContext from './web/ImageManipulatorContext.web';
import ImageManipulatorImageRef from './web/ImageManipulatorImageRef.web';
import { loadImageAsync } from './web/utils.web';
class ImageManipulator extends NativeModule {
Context = ImageManipulatorContext;
Image = ImageManipulatorImageRef;
manipulate(source, options) {
return new ImageManipulatorContext(()=>{
if (typeof source === 'string') {
return loadImageAsync(source, options);
}
// Image refs should provide the `uri` property on Web. It could be either remote url, blob or data url.
if (typeof source === 'object' && 'uri' in source && typeof source.uri === 'string') {
return loadImageAsync(source.uri, options);
}
throw new Error(`Source not supported: ${source}`);
});
}
}
export default registerWebModule(ImageManipulator, 'ImageManipulator');
//# sourceMappingURL=NativeImageManipulatorModule.web.js.map