Skip to main content

3. Options for implementing image and video resizing

There are two main options for resizing and re-encoding media:

Option 1: Using a premade solution, e.g. a CDN's "image optimizer" or similar

While this is convenient, it also has a lot of pitfalls and downsides that need to be considered.

Pros

  • No additional coding effort required

Cons

  • Likely to cost more and be less efficient at compression
  • Some resizing tools don't allow you to specify important parameters, like chroma subsampling, and do not let you choose an encoder to use (which can matter a lot for e.g. JPGs)
  • Usually involves lazy 'on-demand' resizing, which isn't always desirable

Option 2: Doing it yourself

Implementing image and video resizing yourself isn't easy, but can be well worth the pain.

Pros

  • Allows much better control of how the media is resized and re-encoded
  • Lets you resize proactively
  • Will generally result in better filesizes and quality
  • Can cost less if implemented with high performance libraries

Cons

  • A lot more effort than using a pre-built solution
  • Unlike CDN solutions, is a bit more effort to transfer your code between providers due to different cloud computing architecture on different platforms
  • Isn't going to perform well unless you use the correct libraries
  • Requires knowledge of image formats and encoders for best results