Assets change image format via url

is there any way to get an image in a specific format on the fly (i.e. like we can do to resize the image via the asset URL using query strings)?

1 Like

You can use format=WebP or use auto=true to use the best supported format:

Here are a list of all parmeters:

1 Like

Thanks, @Sebastian for the prompt reply. Just did some tests and it’s working. For some reason, if the source asset format is in WEBP, &format=PNG works but not to JPG. Is that by design?

Perhaps because transparency or something like this? Can you give me an example?

there was no transparency…

attached pic

https://i.postimg.cc/FKHX3bGV/Manifold-Gunk-558x460-4.webp

I mean do you have an example URL to your squidex instance where you make the resize.

https://rycocms.azurewebsites.net/api/assets/rycodev/874a04b8-af1c-4fa8-9b97-81c12fd107bb/

Works for me: https://rycocms.azurewebsites.net/api/assets/rycodev/874a04b8-af1c-4fa8-9b97-81c12fd107bb/?format=JPEG

2 Likes

oh my mistake i was doing JPG… :roll_eyes:

1 Like

Quick follow up on auto=true. Will this work when setting the cache parameter as well?

In other words if I was displaying an image with auto=true and cache=8640000 would I be served a cached webp image in a browser like chrome and a cached png/jpg in a browser that didn’t support webp, or would it just render the auto choice on the initial cache only and try to serve the same thing in both browsers?

The cache parameter just sets the output cache for the browser. So the image is cached client side, not server side. So each client should get the correct format.

1 Like

What is expected behavoir here? If I right click on image and do “save image” in browser shall it be saved as .JPEG file? It looks like parameter “format=JPEG” does not do anything

Hi. The extension is actually not changed. This is a good point, but usually it is used for showing the image directly in the browser and then the extension does not really matter. If you need that, just create a feature request please.