Comments (11)
Thank you very much! I will fix it soon!
from cropper.
It's a great tool. :-) Appreciate your work.
On Sunday, July 6, 2014, Fengyuan Chen [email protected] wrote:
Thank you very much! I will fix it soon!
—
Reply to this email directly or view it on GitHub
#34 (comment).
from cropper.
Thanks~ It's OK now.
from cropper.
Nice. I've been testing it and so far no errors. Heh heh. Math.round vs Math.floor. ;-)
from cropper.
Guess I spoke too soon. :-)
There are still some edge cases where the height and y2 can exceed the size of the original image. The issue seems to be with the transformData()
function. The cropper data passed in is correct and from first glance, the passed in ratio multiplier seems good too. But at the most extreme crop areas (cropper size is maxed out in one dimension) the end return of the transformData()
function can slightly exceed the original image size. We're talking 1 pixel per ~ 900. I've only seen this happen on the y dimension although you might want to check the x as well.
This might be solved by having a validation sub-routine to make sure the boundaries are within the naturalHeight and naturalWidth. If a dimension (or both) exceed, data will reduce the exceeding crop dimension by the difference and reduce the other proportionally, taking the aspectRatio in account.
See console output with various console.log()
markers from the source.
from cropper.
Well, I'll check it carefully. Thanks again~
from cropper.
It appears as though something since 14c20fe has negatively affected setData
. It appears to be an internal rounding error causing the results of getData
to be different from the given x1
, y1
, width
, and height
in setData
. Sometimes it's off by 1px, sometimes 2-3px. It can be seen on the demo page, as well.
Here's a soundless video demo showing how changing any of the setData
values fail to properly set the cropper location or size to those given values:
http://screencast.com/t/bP1FlBcq
from cropper.
@nbibler Thank you. I know, It's the reason of using Math.floor
to transform the data. I will try to improve this as soon as possible.
from cropper.
@fengyuanchen , Is the Math.floor or rounding etc. necessary at all? I was looking at the output results of using jcrop for comparison and they're sending pure decimal values as data crop output.
I went ahead and removed all rounding / flooring from the the cropper code and it seems to work just fine. Images and full height crops that were giving me errors before on my server seem to have disappeared.
Without any number adjusting cropper will output stuff like this...
Object {x1: 95.99999999999997, y1: 0, x2: 1920.0000000000002, y2: 1824.0000000000002, width: 1824.0000000000002…}
Which is being happily accepted by the back-end. I don't know if most server-side image processing takes decimal points as input but if this is indicative of the standard - maybe the number adjusting can be removed or at least, an option?
from cropper.
@orangewarp Fine! I will try to improve this in the next version.
from cropper.
@orangewarp I have improve this on v0.4.0, and the difference between input and output is less than 2px.
from cropper.
Related Issues (20)
- 文件加载不完整,等了很久还是这样 HOT 1
- Upload image twice when change image from input type=file
- 请问用在移动端可以很好的使用吗? HOT 2
- Após cortar imagem, mandar ela para um input que está dentro de um form para enviar a imagem para o banco de dados HOT 1
- Cropbox size not able to set
- Cropbox size automatically increases on page zoom HOT 1
- data.textContent not work
- fixed
- Mark cropped area with color or number HOT 1
- Cannot recreate non Rectangular shaped crops HOT 1
- How to create a crop like camscanner using cropper? HOT 1
- Highlight many rectangular areas
- picture seems to move along as we resize the crop box
- Fix default rotation
- 不支持IE11吗 HOT 1
- How to manually set the height and width of the cropbox? HOT 1
- Can you add/remove an image element to cropper object? HOT 1
- In cropperjs, background color does not change after cropping the image and I can't crop images round HOT 2
- How do I upload the selected image to my Java code on form submit()? HOT 1
- Cropper container width and height is not equal canvas width and height HOT 1
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 cropper.