nanxiaobei / antd-img-crop Goto Github PK
View Code? Open in Web Editor NEW🗡 An image cropper for Ant Design Upload
License: MIT License
🗡 An image cropper for Ant Design Upload
License: MIT License
第一次裁剪图片时 若直接移动裁剪部分或直接拉大裁剪边框 裁剪边框会弹到右下角或直接消失
裁剪范围支持拖拽自定义的吗
Hi, Thank you for a great add-on to enable antd to be able to crop and rotate images.
There are two issues that I have spotted.
Sample image that easily replicates the black border when upload:
https://github.com/ricardo-ch/react-easy-crop/issues/148
see this demo: https://codesandbox.io/s/react-easy-crop-demo-with-cropped-output-m0spo?file=/src/styles.js
I was thinking of adding in a colorpicker ability for the user to be able to pick the background color fillspace or have this be done automatically. Perhaps it could be done where the zoom/crop slider is on the popup using something like this: https://github.com/casesandberg/react-color
Using antd-img-crop, How would I be able to change the background color of the fillspace? Would I need to pass in an extra prop?
I thank you in advance.
裁剪之前没有暴露api,无法控制文件过大取消裁剪的操作
I really like the simplicity of antd-img-crop compared to other alternatives. I would like to set the initial dimensions relative to the image size the users uploaded. Is this already possible with antd-img-crop and I missed it or is is it maybe already on your feature roadmap?
'children' to 'ImgCrop' must be 'Upload' or 'Upload.Dragger'
<>
<ImgCrop>
<Upload
listType="picture-card"
>
++++++++++
</Upload>
</ImgCrop>
</>
Hello @nanxiaobei!
I would like to submit a feature idea: have you considered adding a rotation utility to your component? It already does a great job, but it would be amazing with that. If not, are you open to a pull request? We may be able to do that in our team.
Thanks,
I am sorry, I have another problem :(
With crop 3.3.0 my build was fine, but with the new version 3.4.2 I got this error
I try many many times install and unistall different version of another packages like nextjs or antd (because I thought is a problem of the new versions of nextjs or antd, but the problem just occurs when I update antd-img-crop
to 3.4.2
This is my stable dependencies version. If I update crop the build crashes :(
"dependencies": {
"@next/bundle-analyzer": "^9.4.4",
"@reduxjs/toolkit": "^1.3.6",
"@zeit/next-less": "^1.0.1",
"antd": "^4.3.3",
"antd-img-crop": "^3.3.0",
"isomorphic-unfetch": "^3.0.0",
"next": "^9.4.4",
"next-antd-aza-less": "^1.0.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0"
}
I do the crop on the backend side instead of frontend, so I need to send the original file with crop value. Could you expose the onChange function which returns crop value (x, y, width, height) and the original file? It would be nice if we also support the behavior like react-image-crop:
https://github.com/DominicTobias/react-image-crop
Thanks!
Hey! Amazing package, thanks for it.
Problem: I need to upload multiple files, is it possible to crop/rotate a few images at once?
你好, 组件在移动端的时候 剪切小窗和剪切定位不准确, 希望看一下,感谢
我代码是这样写的,是包裹了Uplaod的
`
<Upload
action={isWx ? "/api/uploadToWx": url}
listType="picture-card"
fileList={list}
data={extraData}
onPreview={this.handlePreview}
onChange={v => {
// console.log("上传改变", list, fileList);
let file = v.file, fileList = v.fileList;
let index = _.findIndex(fileList, item => item.uid == file.uid);
if(file){
if(file.status === "done"){
// console.log("上传成功", v.file);
let response = v.file.response;
if(response && response.status === "success"){
let fileItem = {
uid: file.uid,
url: response.url,
status: "done",
};
if(isWx){
fileItem.wx = response.wx;
}
fileList[index] = Object.assign(fileItem);
}
}else if(file.status === "uploading"){
fileList[index] = Object.assign({
uid: file.uid,
// url: "",
status: "uploading",
});
}
}
// console.log("上传组件的值改变", newValue);
onChange(fileList);
}}
{list.length >= num ? null : uploadButton}
`
为什么裁剪的都是图片右上角部分,而且宽高不是设定的宽高,看demo也是这样
png图片被裁剪后体积反而变大了,貌似是改变的图片的位深度这个属性,请问怎么控制这个值不变呢
nextjs 中不会解析node_modules中的less文件,导致报错
建议:
Steps to Reproduce:
ImgCrop
with the following attributes: width = 200
and height = 200
200px
(say 1200x1600)Ok
Expected:
200x200
Actual:
1200x1200
Hello, it's me again. When I use the image cropper inside a form which has other input fields the data, which is stored in the component's state, is cleared after I upload the image. Please check the codesandbox attached for a demo. First, enter the name and age, and then add an image using the cropper. You will see that the component's state is cleared after the image is uploaded.
https://codesandbox.io/s/beautiful-torvalds-frxpk?file=/src/App.js
求在modal里添加自定义的okText和cancelText
Hi,
Need help! I am currently using the plugin and facing an issue, that whenever I import the plugin, It overrides my existing CSS. Any idea why this is happening?
Adding below line of code is creating the issue:
"import ImgCrop from 'antd-img-crop';"
Thanks.
剪裁后的图片特别模糊,100KB的图片剪裁后只有20KB(尺寸没变),请问要如何解决?
Is there a way to use the underlying properties of the react-image-crop
such as minHeight
, minWidth
, etc. since this package depends on it? Also, is there a way to customize the Modal component that shows up when cropping (changing the buttons and footer, for example)?
Thank you!
It would be greate if we can have circular crop area and also programatically conrol the crop area size. If we can pass props to react-image-crop it would work
I have encountered a problem during upload a cropped picture.
When I upload a picture after I cropped it,The picture is displayed as a black photo in IOS.
How can I fix this problem?
if (!Upload.type.defaultProps.beforeUpload) throw new Error(ERR_NOT_ONLY_UPLOAD);
Upload.type.defaultProps
return undefined
with Upload.Dragger
On screenshots, I tried to crop a 10.2mb jpeg image, width 10315px, height 7049px.
Output is 117.1 mb png image, width 7049px, height 7049px;
Working like a charm on desktop, but contain is not working on mobile devices.
<ImgCrop width={350} height={200} contain={true}>
<Upload
action="https://www.、/v2/5cc8019d300000980a055e76"
listType="picture-card"
fileList={fileList}
onPreview={this.onPreview}
onChange={this.onChange}
>
{fileList.length < 3 && "+ Upload"}
</Upload>
</ImgCrop>
<Modal visible={previewShow} onCancel={this.onCancel} footer={null}>
<img src={previewSrc} style={{ maxWidth: "100%" }} alt="preview" />
</Modal>
如题,只能是按比例吗?
Please make it styleable or receive parent custom styling ie @primary-color etc..
When I upload a file like a pdf or a video the cropper doesn't display anything and If I click Ok now I get an error. I want to put restrictions on extensions allowed how to do it? How to handle this error.
demo link
**背景:**想在表单中使用antd4提供的Imgcrop上传并裁剪图片,使用后发现会报找不到refs,请问有办法解决吗?
代码:
{getFieldDecorator('logo')(
<ImgCrop>
<Upload
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
listType="picture-card"
>
上传
</Upload>
</ImgCrop>
)}
报错信息:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
结合antd的Upload组件,裁剪图片以后上传后端接口报文件格式错误,
不结合这个裁剪功能是可以上传的
在用你的组件,首先点个赞。在使用过程中,发现一些问题
1.上传长图,进入无剪裁框
2.点击模态框的时候已经取消裁剪了,但是点击确定按理是不更新图片的
I am trying to use it with antd form:
<Form.Item {...props} valuePropName="file" getValueFromEvent={returnUploadedFileObject}>
<>
{loading ? : ''} Browse
</>
</Form.Item>
But I am not getting any event in returnUploadedFileObject. Is it possible to bind value with form?
Is there a way to allow the user to reopen the modal for editing again?
Line 10 in 282d691
你这里直接引入了css文件 导致antd设置的主题 被你这个css覆盖掉了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.