How do you set Final image size / scale? #525
Answered
by
ValentinH
alanjohnson
asked this question in
Q&A
-
I am trying to set the final image size after cropping. I.e. I want the final image to be 140px x 190px.
|
Beta Was this translation helpful? Give feedback.
Answered by
ValentinH
Apr 4, 2024
Replies: 1 comment 4 replies
-
What code are you using to crop the image and get the final image? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an example where we force the final image width to be 300px: https://codesandbox.io/p/sandbox/react-easy-crop-demo-with-cropped-output-forked-l9xmfs?file=%2Fsrc%2FcropImage.js%3A71%2C21
The trick for this is to use the first parameter of the onCropComplete callback which is using percentage values.
Then, I've slightly adjusted the
getCroppedImg
function to use percentage values and force the final image dimensions.