tldraw/packages/utils
alex 39cb6bf49b
fix png images with pixel ratios <0.5 crashing the app (#2350)
When we handle pixel ratios in .png files, we were rounding the pixel
ratio to the nearest integer. This mean that if an image had a pixel
ration less than 0.5, it would get rounded to zero. This would cause a
divide-by-zero on the width & height of the image which would crash the
app.

This has a couple fixes:
- we ignore pixel ratios less that 1
- we perform rounding _after_ we apply the pixel ratio to the
width/height

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Upload this funky image:
![shapes_5](https://github.com/tldraw/tldraw/assets/1489520/80fb41fa-3be1-4dbd-8e2f-d81013b09780)
2. Check the app doesn't crash
2023-12-19 12:35:42 +00:00
..
api Publish api.json (#2034) 2023-10-08 15:00:58 +00:00
src fix png images with pixel ratios <0.5 crashing the app (#2350) 2023-12-19 12:35:42 +00:00
api-extractor.json transfer-out: transfer out 2023-04-25 12:01:25 +01:00
api-report.md fix vite HMR issue (#2279) 2023-12-01 16:48:30 +00:00
CHANGELOG.md Update CHANGELOG.md [skip ci] 2023-12-12 14:50:43 +00:00
LICENSE.md Change licenses to tldraw (#2167) 2023-12-19 10:41:01 +00:00
package.json Change licenses to tldraw (#2167) 2023-12-19 10:41:01 +00:00
README.md Change licenses to tldraw (#2167) 2023-12-19 10:41:01 +00:00
tsconfig.json transfer-out: transfer out 2023-04-25 12:01:25 +01:00

@tldraw/utils

This package contains utility functions used in various places by other tldraw packages.

Community

Have questions, comments or feedback? Join our discord or start a discussion.

Distributions

You can find tldraw on npm here.

Contribution

Please see our contributing guide. Found a bug? Please submit an issue.

License

The tldraw source code and its distributions are provided under the tldraw license. This license does not permit commercial use.

If you wish to use this project in commercial product, you need to purchase a commercial license. matPlease contact us at hello@tldraw.com for more inforion about obtaining a commercial license.

Trademarks

Copyright (c) 2023-present tldraw Inc. The tldraw name and logo are trademarks of tldraw. Please see our trademark guidelines for info on acceptable usage.

Contact

Find us on Twitter at @tldraw or email hello@tldraw.com. You can also join our discord for quick help and support.