Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React.Image returns not the real size of the image #32031

Closed
valery-lavrik opened this issue Aug 18, 2021 · 4 comments
Closed

React.Image returns not the real size of the image #32031

valery-lavrik opened this issue Aug 18, 2021 · 4 comments
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@valery-lavrik
Copy link

valery-lavrik commented Aug 18, 2021

Hey!
The Image component does not return the actual size of the image.
I connect to the image an image with a size of 720x5373 pixels.
But in onLoad I get dimensions - 240x1791 pixels.
This leaves some padding in the image. Why is the size different?

Even the Image.getSize method returns the wrong dimensions ...
2021-08-18_09-06-21

`
import React, { useState } from "react";
import { Image, ScrollView, Dimensions } from "react-native";

const App = () => {
const [W, setSizeW] = useState(null);
const [H, setSizeH] = useState(null);

let imageW = null;
let imageH = null;
if (!!W && !!H) {
	imageW = parseInt(Dimensions.get('window').width, 10);
	const ratio = W / imageW;
	imageH = parseInt(H * ratio, 10);
}

return (
	<ScrollView>
		<Image
			onLoad={(e) => {
				console.log('e.nativeEvent?.source', e.nativeEvent?.source);
				setSizeW(e.nativeEvent?.source?.width);
				setSizeH(e.nativeEvent?.source?.height);
			}}
			resizeMode="contain"
			style={{
				width: imageW,
				height: imageH,
			}}
			source={{ uri: 'http://www.comics-api.lavrik.site//comic/proxy?q=3019995&type=page&dd' }}
		/>
	</ScrollView>
);

};
`

I can't find the reason for several days
More like a bug

It seems that the reactant itself compresses the image ...
Can this be disabled somehow?

@valery-lavrik
Copy link
Author

I studied thread - facebook/fresco#2397 , and realized that I need to make it possible to turn off the down-scaling in the fresco

Is this planned to be done?

@valery-lavrik
Copy link
Author

Found a workaround to use react-native-fast-image instead of Image

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 25, 2022
@github-actions
Copy link

github-actions bot commented Apr 1, 2022

This issue was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this as completed Apr 1, 2022
@facebook facebook locked as resolved and limited conversation to collaborators Apr 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

1 participant