Comments (7)
@nickensoul are you trying to pass pixel values? The values are 0-100%. It can be a bit inconvenient but this is how the library is responsive (by using %). You can convert to a % if you like by setting the values in onImageLoaded
as there you have the image object which has the width and height.
from react-image-crop.
@dominictobias thanks for the quick reply!
Yep, according to the docs I'm trying to pass number as a percentage values. As mentioned above, I use it this way:
<ReactCrop
src={src}
crop={crop}
minHeight={100}
maxHeight={100}
onImageLoaded={this.onImageLoaded}
onComplete={this.onCropComplete}
onChange={this.onCropChange}
/>
But I've got it. If I set e.g. minHeight={50}
, it works fine, but if more – doesn't. Actually, it works, but unexpected: if minHeight
is 80, then start position of drag must be such that actual selection height' height is at least 80. In other worlds, start position of the drug may be in edges of image only at Y axis, e.g. for minHeight={80}
, it is 20% of image on its edges. So if minHeight={100}
, it's impossible to get position of start at <= 0% or >=100% of image height in coordinates.
Sorry for my English, that's was hard to explain 😆
from react-image-crop.
Hi are you using the latest version? Also post what props you are passing to the component please
from react-image-crop.
Hi,
I'm using the v1.0.0-rc8.
The props i pass to the component are:
src={this.props.src}
onImageLoaded={this.onImageLoaded}
onComplete={this.onCropComplete}
crop={crop}
outputPixelUnits={true}
where crop
has these fields:
crop.x = this.props.imageState.x / naturalWidth * 100;
crop.y = this.props.imageState.y / naturalHeight * 100;
crop.height = this.props.imageState.height / naturalHeight * 100;
crop.width = this.props.imageState.width / naturalWidth * 100;
// TODO the following are only test values
crop.minWidth = 25;
crop.minHeight = 25;
I would expect to have a min crop area as big as the 25% of the total image area. But apparently it does not work that way.
from react-image-crop.
@riccardolorenzon rather than passing the minHeight/maxHeight into the crop object, pass it as a prop - e.g.
crop={crop}
minHeight={25}
maxHeight={25}
from react-image-crop.
Closing - let me know if you have probs with that fix
from react-image-crop.
Hello!
I've just tried to set minHeight={100}
and maxHeight={100}
in demo codesandbox but it doesn't work, I just cannot select anything at all.
What am I doing wrong?
Thanks!
from react-image-crop.
Related Issues (20)
- when we have circularCrop as prop, how to set the points on circle? HOT 3
- Need to rotate selected(croped) image HOT 4
- Synchronization Issue Between Multiple Cropper Instances on the Same Page HOT 2
- Image Cropping with 8/3 Aspect Ratio Causing Loss of Half Portion After Retrieval for s3 HOT 2
- Canvas toBlob crop not working on Sandbox (iOS) HOT 3
- Crop mask stays present with zero-size crop HOT 1
- SecurityError: OffscreenCanvas.convertToBlob: Cannot get blob from write-only canvas. HOT 1
- Canvas returns null after cropping image iOS HOT 1
- Mask is does'nt showing the first time HOT 6
- Memory leak risk due to event listeners not removed on componentWillUnmount HOT 1
- mask does not fully cover the image when the image to a smaller aspect ratio HOT 2
- Multiple crop selection on an image at the same time HOT 1
- Can the cropper be used for outpainting?
- React Crop as Dialog Box
- The previous image layout still be kept after switch image
- Feature request: Add the option to rotate the crop selection
- Proportional Stretching of Crop Box
- iPhone 15's 24 MP (res 4284 X 5712) image resolution is making the image black after cropping. HOT 1
- Library not supporting image cropping in iOS WebView HOT 6
- Add whitespace around image being cropped?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-image-crop.