react-native-image-resizer
react-native-image-resizer copied to clipboard
'cover' mode does not work as expected
Describe the bug
The definition of 'cover' in other contexts means the image is clipped to fit the container. In this library cover
chooses width or height but does not respect both. In, for example, CSS the object-fit: cover
property clips the left/right or top/bottom when the image content does not fit inside the container size.
It would be nice if this library at least had an additional property (crop
?) to achieve this for quick cropping to the image center.
To Reproduce Steps to reproduce the behavior:
- Run the following on any image that doesn't have dimensions 768x512:
ImageResizer.createResizedImage(
media.path,
768,
512,
"JPEG",
50,
0,
undefined,
false,
{
mode: "cover",
onlyScaleDown: false,
}
)
Observed behavior
The resulting image will be either 768px wide or 512px tall but not both and will maintain the original images aspect ratio. (I understand this is the documented behavior, but it is not the standard cover
behavior in other contexts).
Expected behavior I would expect the resulting image to be exactly 768x512 with either top sides cropped equally or the top and bottom cropped equally.
Screenshots
Platform concerned:
- Device: iPhone13 Pro
- OS: iOS17.2
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.
Same issue still today
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.
This issue has been automatically closed. Thank you for your contributions.