clearfram3
clearfram32mo ago

File and image compression workflows

What's the best way to compress images before putting them in convex file storage?
5 Replies
clearfram3
clearfram3OP2mo ago
This is what I have narrowed down: - compression: use JIMP on client, sharp in Convex action-compute, or sharp in Cloudflare worker - meta-data: convex db (of course) - actual file storage: convex or R2
deen
deen5w ago
you mean optimization? i've used a cloudflare worker in the past and been happy with it. not their Images plan, just using image transform in a worker. I stored the data in convex but I regret it, I've been meaning to export it to R2. Instead the worker can serve the images as well. That's what I would do next time. I'm not sure how that would fit in with the R2 component and yeah sharp on convex if you don't want to use a worker
clearfram3
clearfram3OP5w ago
You regret it because of speed, cost, usability, or functionality?
deen
deen5w ago
I'm not near US-EAST. Cloudflare "feels" faster to me - probably because they're able to proxy assets to my city, but I've never really looked into it. Cloudflare has built in functionality to optimise images to the requested parameters on demand - it works really well with the next.js image component for example. Once I moved my optimization workflow to Cloudflare, I could delete quite a bit of action/mutation code in convex, replacing it with a fairly simply cloudflare worker instance that was mostly copypasted from their docs. I never moved my actual main file storage - I have about 26GB worth of user images. It's not costing me anything with the convex pro plan, there's no cost advantage, yet. There's nothing wrong with using the convex file store - it's simpler in a way if you're not familiar with the Cloudflare ecosystem. But it has no advantages apart from it being there already.
clearfram3
clearfram3OP5w ago
The optimization feature going from server to users is really good. For my usecase, I need optimization before it gets to the server I think I only need to worry about R2 then There's no ingress fee for convex, but the egress fee is 2x the ingress fee of R2 and the storage fee is 2x the R2 storage fee Seems like they should cut a deal with Cloudflare and charge 10c over R2 charges

Did you find this page helpful?