1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/packages/app-mobile/utils/image/getImageDimensions.ts

23 lines
488 B
TypeScript
Raw Normal View History

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;