mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
23 lines
488 B
TypeScript
23 lines
488 B
TypeScript
import { Size } from '@joplin/utils/types';
|
|
import { Image as NativeImage } from 'react-native';
|
|
|
|
const getImageDimensions = async (uri: string): Promise<Size> => {
|
|
if (uri.startsWith('/')) {
|
|
uri = `file://${uri}`;
|
|
}
|
|
|
|
return new Promise((resolve, reject) => {
|
|
NativeImage.getSize(
|
|
uri,
|
|
(width: number, height: number) => {
|
|
resolve({ width: width, height: height });
|
|
},
|
|
(error: unknown) => {
|
|
reject(error);
|
|
},
|
|
);
|
|
});
|
|
};
|
|
|
|
export default getImageDimensions;
|