Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix crop with downsamplingRatio #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2017
Merged

fix crop with downsamplingRatio #85

merged 1 commit into from
Feb 16, 2017

Conversation

fleg
Copy link
Contributor

@fleg fleg commented Feb 13, 2017

It not actually broken, because I can't get canvas data (Tainted canvases may not be exported).
I append cropped image to body, and it transparent, but it should be black.

I think, bug in renderImageToCanvas calling with non-zero sourceX and sourceY in cycle, and image just moving out beyond the border of canvas.

If you agree, I can fix it, but I don't know how to check content of cropped image in test

@blueimp
Copy link
Owner

blueimp commented Feb 15, 2017

Thanks for your contribution, @fleg

To check the content of the image, you'll need to retrieve the canvas Image data.
You'll get back an ImageData object with a data property representing a one-dimensional array containing the data in the RGBA order, with integer values between 0 and 255 (included).

@fleg
Copy link
Contributor Author

fleg commented Feb 15, 2017

getImageData throws error in browser (because of file:/// protocol), but if perfectly working in phantomjs, and now test failing

@fleg
Copy link
Contributor Author

fleg commented Feb 15, 2017

I fix scale, but it hard to properly test this feature with single colored image

@fleg fleg changed the title add broken test case for crop with downsamplingRatio fix crop with downsamplingRatio Feb 15, 2017
@blueimp
Copy link
Owner

blueimp commented Feb 15, 2017

Thanks, I think your test is sufficient.

Just one note regarding your fix:
Instead of introducing another variable (cropped), please simply add the following two lines after the first loadImage.renderImageToCanvas call in the downsampling loop:

          sourceX = 0
          sourceY = 0

After this change, please squash your commits into one (or two if you want to add the test separately).
Then I'll merge your changes gladly. :)

@fleg
Copy link
Contributor Author

fleg commented Feb 15, 2017

done

@blueimp
Copy link
Owner

blueimp commented Feb 16, 2017

Perfect, thanks!

@blueimp blueimp merged commit 42028c8 into blueimp:master Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants