react-native-image-resizer icon indicating copy to clipboard operation
react-native-image-resizer copied to clipboard

[Question] Get output width and height?

Open cristianoccazinsp opened this issue 6 years ago • 1 comments

Is it possible to get the final width and height of the image after resize?

cristianoccazinsp avatar May 07 '19 18:05 cristianoccazinsp

You can write your own function to do that

import {Image} from "react-native";

export async function getImageDimensions(imageUri) {
    return new Promise((resolve, reject) => {
            Image.getSize(imageUri, (width, height) => {
                resolve({width, height});
            }, error => reject(error));
        }
    );
}

Usage:

const imageDimensions = await getImageDimensions(pathToImage);

You can use this in combination of the image resize function to return both the path to the new image and its dimensions

bureyburey avatar Jun 06 '20 10:06 bureyburey

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 01 '22 19:09 stale[bot]

This issue has been automatically closed. Thank you for your contributions.

stale[bot] avatar Sep 09 '22 03:09 stale[bot]