Skip to content

useImageResolution hook

Get the resolution of a network, bundle or base64 image.

How to use

jsx
import { useImageResolution } from 'react-native-zoom-toolkit';

// Network image
const { isFetching, resolution, error } = useImageResolution({
  uri: 'url to some network image',
  headers: {
    Authorization: 'some bearer token',
  },
});

// Bundle image
const { isFetching, resolution, error } = useImageResolution(
  require('path to your bundle image asset')
);

// Base64 image
const { isFetching, resolution, error } = useImageResolution({
  uri: 'your base64 string',
});

Type Definitions

FetchImageResolutionResult

PropertyTypeDescription
isFetchingbooleanWhether the hook is fetching or not.
resolutionSizeVector | undefinedWidth and height of the image.
errorError | undefinedAn error in case the image fetching fails.

Released under the MIT License.