tldraw/packages
Mitja Bezenšek 0171d1498d
Fix downscaling (#2325)
Fixes an issue where uploaded images could significantly increase the
document size. The problem was with calling `downscale` library, which
expect the type to be one of: `jpg`, `png`, `webp`. We were sending the
type with the `image/` prefix. Thanks to @irg1008 for pointing that out.

Test image:

![testImage](https://github.com/tldraw/tldraw/assets/2523721/b8df54ca-60f4-47a4-8b71-ca6ba6ca1935)

The difference I saw in testing:
![CleanShot 2023-12-15 at 10 34
56](https://github.com/tldraw/tldraw/assets/2523721/cf571ac9-4af0-4ac0-af3f-3dfbbe5cdd85)

@steveruizok why are we[ doubling the size
here](https://github.com/tldraw/tldraw/blob/main/packages/tldraw/src/lib/utils/assets/assets.ts#L61-L62)?
For retina quality?

Fixes https://github.com/tldraw/tldraw/issues/2320

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version

### Test Plan

1. Use the supplied test image.
2. Add it to a tldraw document.
3. Save the file and check the file size. It should be significantly
lower than doing the same thing on tldraw.com

- [ ] Unit Tests
- [ ] End to end tests

### Release Notes

- Decrease the size of uploaded assets.
2023-12-15 17:13:36 +00:00
..
assets Update CHANGELOG.md [skip ci] 2023-12-12 14:50:43 +00:00
editor Update CHANGELOG.md [skip ci] 2023-12-12 14:50:43 +00:00
state Use a global singleton for tlstate (#2322) 2023-12-14 13:35:34 +00:00
store Update CHANGELOG.md [skip ci] 2023-12-12 14:50:43 +00:00
tldraw Fix downscaling (#2325) 2023-12-15 17:13:36 +00:00
tlschema Update CHANGELOG.md [skip ci] 2023-12-12 14:50:43 +00:00
utils Update CHANGELOG.md [skip ci] 2023-12-12 14:50:43 +00:00
validate Update CHANGELOG.md [skip ci] 2023-12-12 14:50:43 +00:00