Skip to content
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

detectVerticalSquash bug for transparent PNG #45

Open
av01d opened this issue Mar 1, 2016 · 2 comments
Open

detectVerticalSquash bug for transparent PNG #45

av01d opened this issue Mar 1, 2016 · 2 comments

Comments

@av01d
Copy link

av01d commented Mar 1, 2016

There's an issue when using megapix-image.js on some transparent PNG's.
The issue is described in detail here: dropzone/dropzone#813
I managed to find and fix the problem, it's a 1 character fix.
In the detectVerticalSquash function, change this:

var data = ctx.getImageData(0, 0, 1, ih).data;

to this:

var data = ctx.getImageData(1, 0, 1, ih).data;

That's all. The library will work as before, and the problem with transparent PNG's is now fixed.

@diegocr
Copy link
Contributor

diegocr commented Mar 10, 2016

Hi, the changes you're suggesting are for the function detectVerticalSquash which is not used for PNG files, only for image/jpeg ones (see #18)

However, playing with the image http://i.imgur.com/lxfQQqa.png as pointed in dropzone/dropzone#813 I was able to reproduce the stretch problem, which is being caused here from the detectSubsampling function, that one is indeed used for any image.

For the sake of, i tried to apply the same kind of fix:

return ctx.getImageData(0, 0, 1, 1).data[3] === 0;

to this:

return ctx.getImageData(1, 0, 1, 1).data[3] === 0;

but it doesn't seems to fix the problem, kinda odd.

@zulalay
Copy link

zulalay commented Mar 14, 2016

in my case as well detectVerticalSquash function is called from renderImageToCanvas() method

i fixed it by commenting out some code
var alpha = data[(py - 1) * 4 + 3];
//if (alpha === 0) { //that fixes issue when it cant save png with transparent screen
// ey = py;
//} else {
sy = py;
//}
didnt find any bad influence yet but needs more testing :)

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

No branches or pull requests

3 participants