Skip to main content
If your images live in R2 and you connected the bucket, toDreepUrl() turns the URLs you use today into Dreep URLs. The file’s path and any transform options stay the same.
It’s pure string work: no API key, no client, no network call.

Signature

It swaps from for to, and turns /cdn-cgi/image/ into /_img/. Cloudflare reserves /cdn-cgi/ on every domain it serves, so Dreep reads the same options under /_img/. A URL that doesn’t match from comes back unchanged, so you can run it over everything you store.

Presets in the path

If your own image worker puts a size in the path, like /i/lightbox/<file>, mark that position in from with :preset:
to is your Images URL from Settings > Storage. If you’ve pointed your own domain at Dreep, use that instead, such as https://images.example.com.
  • A preset listed in presets gets those settings.
  • Any other preset becomes ?p=<name>, so create a Dreep preset with the same name. If there’s no such preset, Dreep answers 400.
  • A URL with no file after the preset, like /i/lightbox, comes back unchanged.

Keeping your own domain

If you point your own domain at Dreep, pass it as both from and to. Only /cdn-cgi/image/ changes:

Updating stored URLs

Run it once over the URLs in your database:
Back up the table first. For a single SQL statement instead, see In your database.

Resizing the new URLs

Pass transform to add options while converting:
A preset’s settings win where both set the same option. The result also works with url() like any other Dreep URL: