react-native-zoom-toolkit: [Bug]: Error: maxWidth and maxHeight parameters are undefined, provide at least one of them when image is square
Summary
Hi, thank you for creating this module.
I’m encountering this error when the image is a square eg. 1280x1280:
Error: maxWidth and maxHeight parameters are undefined, provide at least one of them
When I change the height:
to:
aspectRatio >= 1 ? maxHeight : undefined
The image loads fine and I get this warning:
CropZoom inferred a max crop height of 329.14285714285717, but received a crop height of 386, your cropSize property's height has been clamped to 329.14285714285717
I tried it with this image:
Click me
I’m not doing something fancy, just followed the common /example
ps. I’m also not rotating or trying to rotate the image.
Environment
rn 0.74.1
Steps to Reproduce
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 25 (12 by maintainers)
@efstathiosntonas It’s good to know it works, even the simplest ideas can turn into tricky and insufferable thoughts when some level of Math is involved in particular for a self taught like myself, however your issue has been quite fun to work with, I would have not thought of changing the way the image renders without looking at what you’re attempting to create, so for that all I can say is thanks.
I think the new version may be published by the end of this day, with this outcome I consider this issue to be closed for good now.
Yes, with and without the
fixedWidthparameter.@efstathiosntonas Whatever I tell you may be a lie as I’m not sure why it happens, all I know is that RN has a lot non sense stuff I will never be able to comprehend, one just has to flow with them against one’s desires, I’m happy the blur went it away nonetheless.
In terms of the crash I made a few adjustments to the lib, everything seems fine here lib.tar.gz , the order was fixed to be the one in the docs again https://glazzes.github.io/react-native-zoom-toolkit/guides/cropzoomexpo.html#crop-method, sorry for the inconvenient, give it a try.
@efstathiosntonas Hi there, just to give you an update on how this thing is going, last days have been the wrost of my life in terms of mental health so you’ll have to wait for a little longer.
Sizing right now is working really good, better than before, however the cropper is still fully broken when using the
fixedWidthargument, pretty much this is how they look now for all three different aspect ratios, while using at the same time the three different aspect ratios on the imgaes, one per each ratio.@efstathiosntonas Hi there, just to give you an update, dealing with square content has proven to be more annonying than I expected, it may take a few days for me to figure out the math to make the square content fit properly in crop sizes which aspect ratio is not one, I was working on it yesterday and it did work as I expected but it broke the cropper entirely, so yeah pretty much that for the moment.
Bare with me.
@efstathiosntonas Could you hand me the code of what you’re currently building? This way I can investigate further, btw remove
flex: 1from styles, it’s either flex or width and height, not both.Just released version 1.2.2, give it a try!
I saw the same problems with the image in the issue, sadly that’s something I’ve no control over, I tried the image and it was rendered properly using
{width: '100%', height: '100%'}, also remember image scaling behaviour on Android depends on what RN thinks is best, so set Image’sresizeMethodproperty toscale.Give it a try and let me know.
Hi there, the warning is meant to be a harmless indication that the crop dimensions are bigger than the size the image is occupying in the screen, it does not affect the functionality as far as I am concerned, however before I release the new version with the fix I’d like to know if you had success cropping the image after the small
>=change, because everything seems working fine on my end.