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

Ensure resizeImage's canvas has at least 1px of width and height #2409

Merged
merged 2 commits into from
Jul 4, 2021

Conversation

cheapsteak
Copy link
Contributor

@cheapsteak cheapsteak commented Nov 3, 2020

Summary

This PR fixes/implements the following bugs/features

Explain the motivation for making this change. What existing problem does the pull request solve?

CanvasRenderer.resizeImage throws when passed in an image that, after resizing, has a height of less than 1px

Test plan (required)

Added a test for background image slivers to reftests/background/size.html

Have tested that test fails with Failed to execute 'createPattern' on 'CanvasRenderingContext2D' error before the fix, and passes after the fix

Closing issues

Fixes #2408

@abdurrahmanyildirim
Copy link

abdurrahmanyildirim commented Sep 10, 2021

Hi @cheapsteak , Could you update your solution with this ?

canvas.width = isNaN(width) || width === 0 ? 1 : width;
canvas.height = isNaN(height) || height === 0 ? 1 : height;

At my app, width comes with NaN value and Math.max(1,width) gives NaN result so it gives error.

@niklasvh Could you update this solution?

ahebrank added a commit to ahebrank/frontback that referenced this pull request Oct 28, 2021
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.

Error when drawing images with fractional heights that scale to less than 1px
3 participants