Skip to main content
uploadImage(endpoint, file) reads an image file, scales it down to at most 1600 px on its longest edge, and posts it to an image endpoint as a data URI. It resolves with where the image now lives.

Contract

The endpoint receives { image: "<data URI>" } and must answer { image: { url, width, height, bytes } }. The server does the real compression, producing a much smaller WebP than a browser canvas can and applying the photo’s EXIF orientation, so portrait photos do not arrive sideways.

Errors

uploadImage throws ImageUploadError rather than resolving empty, so a failed upload is never silently dropped. error.reason is one of: