Skip to content

How do you set Final image size / scale? #525

Answered by ValentinH
alanjohnson asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@alanjohnson
Comment options

@ValentinH
Comment options

Answer selected by alanjohnson
@alanjohnson
Comment options

@ValentinH
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants