Image Resizing Format

Hi! I have something like the following running on a worker on a Pro site. The image is resized to the indicated height & width, but the content format remains image/jpeg. Does anyone know what I might be missing to have it take into account the proper format?

Thanks!

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  const options = {
    cf: {
      image: {
        fit: 'cover',
        format: 'webp',
        height: 1000,
        width: 1000
      }
    } 
  }
  return fetch(new Request('example.com/image.jpg'), options)
}

I opened support ticket 2575250 as well.

Hi, do you see any warning response headers?

Thanks @asemiglazov ! I see a header that indeed indicates that the image is too large for webp.

In this tested case, the image winds up being 4800 x 4800 pixels. In jpeg format its 1.67 MB. I wouldn’t see how it could be too large for webp. From Google’s docs, webp has max pixel dimensions of 16383 x 16383

Do you have any thoughts on why it would indicate that it is too large?

warning : cf-images 299 “image too large for WebP”

yes, this is not a limitation of standard, rather our decision on a computational effort, since WebP is “heavier” codec than JPEG.

I’m curious what are these dimensions for 4800x4800?

4800 x 4800 is just the most recent base image I tested that received the too large for webp error

This topic was automatically closed after 15 days. New replies are no longer allowed.