Skip to main content

October 6, 2024

How to Decrease Image Size to Improve SEO Free and Easy Way to Convert Images to AVIF

11 min read

Optimize images for SEO

If you've recently started using Webflow, you might have noticed that it now supports the AVIF image format, which is great news for optimizing load times. Webflow has a tool that will convert your CMS images to AVIF, but there's a catch: it won't do the same for images inside rich text fields.

When adding images to your blog posts or other rich content, manually converting them to AVIF can make a noticeable difference in performance, but it can also be time-consuming and costly if you rely on online services that require subscriptions.

Luckily, there's a better way. By using your terminal, you can easily convert images to AVIF directly on your machine—faster and without the cost.

In this blog post, I'll walk you through a simple, effective, and entirely free method for converting your images to AVIF before uploading them to Webflow, saving you time and helping your site load even faster.

Get Your Machine Setup

If you have Node.JS and NPM installed on your machine, you can skip to the next section.

Step 1: Install Node.JS on Your Machine

If you haven’t installed Node.JS, you can do so by downloading the package and installing it here: https://nodejs.org/en

Step 2: Install NPM on Your Machine

Here are step by step instructions on how to install NPM https://docs.npmjs.com/downloading-and-installing-node-js-and-npm

Use AVIF CLI Utility

On Github, Lovell has released a helpful utility to convert images to AVIF using the CLI (Terminal). You don’t have have to upload your images to a service online, nor do you need to pay for a service. With a little Terminal Knowledge, you can handle everything locally on your machine. This speeds up conversion of images drastically, while providing you control of quality and speed output.

Here is the Github Repository: https://github.com/lovell/avif-cli

First time you run the command

The first time you run the command, you will need to install some items on your computer. On Mac, at least, it asked for access to a number of folders. I didn’t grant it access to all my folder where images were housed, just the main folders on my actual computer.

Run

npx avif

Then answer yes when asked to install.

After everything is installed, you will follow the following directions:

Step 1: Navigate to Your Directory

Open your Terminal and navigate to the directory:

Here is how you get the directory path

__wf_reserved_inherit
  • Right click on the folder
  • Get info
  • Copy PathWhen you copy the path from the info panel, you will most likely get the parent folder and not the entire path: /Users/caseylewis/DownloadsNotice, I didn’t get the entire path, which would include the SEO Audit folder.Make sure you add the folder name to the path once you have pasted the path into the terminal.
  • When you copy the path from the info panel, you will most likely get the parent folder and not the entire path: /Users/caseylewis/Downloads
  • Notice, I didn’t get the entire path, which would include the SEO Audit folder.
  • Make sure you add the folder name to the path once you have pasted the path into the terminal.

In the terminal, you will change the directory to the folder where the images are located. You do that using the cd command.

cd /Users/caseylewis/Downloads/SEO\ Audit

Or:

cd "/Users/caseylewis/Downloads/SEO Audit"

Make sure to write your directory path correct

If you folder has a space like mine SEO Audit, then you need to use a backspace in-between the words or put quotes around the entire path.

The reason I wrote the directory navigation command like this:

cd /Users/caseylewis/Downloads/SEO\ Audit

is because the folder name "SEO Audit" contains a space. In the command line, spaces are typically treated as separators between different arguments. To correctly represent a folder name with a space in it, you need to escape the space so the terminal knows it's part of the same name.

Here's a breakdown:

  • Backslash \: Escapes the space character, telling the terminal that the space is part of the directory name and not an argument separator.
  • Alternatively, you can wrap the entire path in quotes, which also works if there are spaces:
  • cd "/Users/caseylewis/Downloads/SEO Audit"

Both approaches ensure that the terminal reads SEO Audit as one complete folder name rather than trying to interpret it as two separate words.

If you would like a third approach that is even more straightforward, see my post on resizing images using the Terminal.

Step 2 (Optional): Make a New Directory for the Converted Images

This step is optional, but I suggest it so your converted files are in a new folder.

If you want to add the converted images to a new folder, which I like to do, then I’d suggest you make a new directory. Making a new directory just means that you make a new folder.

Add the new folder wherever you like.

You can use the command line or you can just create a new folder like you normally would.

Just make sure you copy the path to the new folder where you want the output to go.

Here is how you would use the command line to make a new directory (folder).

Notice, I am making a new directory or folder inside of my SEO Audit folder. The new directory or folder is named edited.

mkdir "/Users/caseylewis/Downloads/SEO Audit/edited"

Step 3: Convert Your Image Files to AVIF

Once you're in the correct directory, you can run the following command to convert all your images to .avif files.

In this case, I am converting all my .png files to .avif:

npx avif *.png --quality 80 --output "/Users/caseylewis/Downloads/SEO Audit/edited"

This command will:

  • Convert all .png files in the folder to .avif.
  • Set the quality to 80.
  • Output them to /Users/caseylewis/Downloads/SEO Audit/edited the new folder I created.

Options

The following options are available when converting your files.

Notice there are defaults. If you are good with the defaults, you don’t need to provide the options, you can simple run the command npx avif, if you have navigated the terminal to the directory where the image files are located.

--input Input file name(s), supports globs/wildcards [string] [default: "*.{jpg,jpeg,tif,tiff,webp,png,gif,svg}"]

--output Output directory, default is same directory as input[string] [default: ""]

--quality Quality vs file size, 1 (lowest/smallest) to 100(highest/largest)[number] [default: 50]

--effort CPU effort vs file size, 0 (fastest/largest) to 9 (slowest/smallest)[number] [default: 4]

--lossless Use lossless compression [boolean] [default: false]

--chroma-subsampling Set to '4:2:0' to use chroma subsampling [string] [choices: "4:2:0", "4:4:4"] [default: "4:4:4"]

--keep-metadata Keep all metadata (EXIF, ICC, XMP, IPTC)[boolean] [default: false]

--overwrite Allow existing output files to be overwritten [boolean] [default: false]

--append-ext Append .avif to the file name instead of replacingthe current extension (foo.jpg => foo.jpg.avif)[boolean] [default: false]

--verbose Write progress to stdout [boolean] [default: false]

-h, --help Show help [boolean]--version Show version number [boolean]

Command-Line Options Breakdown

  1. --inputDescription: Specifies the input file(s) to be converted.Usage: You can use file names, globs, or wildcards to specify multiple files.Default: "*.{jpg,jpeg,tif,tiff,webp,png,gif,svg}" (This means by default, it will try to convert all files of these types in the current directory).If you want all files of the supported types to be converted, you simply run the command without the --input flag, and it will use the default pattern for that directory. If you want to specify only certain files or use a custom pattern, you use --input.Example: --input myfile.png or --input "*.jpg"NOTE: If you are already in the directory containing the files, you do not need to provide the --input flag explicitly. The tool will automatically take all the files matching the default pattern (*.jpg, *.png, etc.) from the current directory.
  2. Description: Specifies the input file(s) to be converted.
  3. Usage: You can use file names, globs, or wildcards to specify multiple files.
  4. Default: "*.{jpg,jpeg,tif,tiff,webp,png,gif,svg}" (This means by default, it will try to convert all files of these types in the current directory).If you want all files of the supported types to be converted, you simply run the command without the --input flag, and it will use the default pattern for that directory. If you want to specify only certain files or use a custom pattern, you use --input.
  5. If you want all files of the supported types to be converted, you simply run the command without the --input flag, and it will use the default pattern for that directory. If you want to specify only certain files or use a custom pattern, you use --input.
  6. Example: --input myfile.png or --input "*.jpg"
  7. NOTE: If you are already in the directory containing the files, you do not need to provide the --input flag explicitly. The tool will automatically take all the files matching the default pattern (*.jpg, *.png, etc.) from the current directory.
  8. --outputDescription: Specifies the output directory where the converted .avif files will be saved.Default: Same directory as the input files.Example: --output /path/to/output-folder/
  9. Description: Specifies the output directory where the converted .avif files will be saved.
  10. Default: Same directory as the input files.
  11. Example: --output /path/to/output-folder/
  12. --qualityDescription: Controls the quality of the output image. The value can be between 1 and 100, where 1 is the lowest quality and smallest file size, and 100 is the highest quality and largest file size.Default: 50 (A balance between quality and compression).Example: --quality 80 (This produces a higher quality image with less compression).
  13. Description: Controls the quality of the output image. The value can be between 1 and 100, where 1 is the lowest quality and smallest file size, and 100 is the highest quality and largest file size.
  14. Default: 50 (A balance between quality and compression).
  15. Example: --quality 80 (This produces a higher quality image with less compression).
  16. --effortDescription: Sets the level of CPU effort during compression. A value of 0 is the fastest (with larger file size), while 9 is the slowest but provides the smallest possible file size.Default: 4 (A reasonable compromise between speed and size).Example: --effort 8 (This will result in smaller files but may take longer to process).
  17. Description: Sets the level of CPU effort during compression. A value of 0 is the fastest (with larger file size), while 9 is the slowest but provides the smallest possible file size.
  18. Default: 4 (A reasonable compromise between speed and size).
  19. Example: --effort 8 (This will result in smaller files but may take longer to process).
  20. --losslessDescription: Uses lossless compression to preserve all image details without quality loss.Type: Boolean (true or false).Default: false (Meaning lossy compression will be used).Example: --lossless (This will enable lossless compression).
  21. Description: Uses lossless compression to preserve all image details without quality loss.
  22. Type: Boolean (true or false).
  23. Default: false (Meaning lossy compression will be used).
  24. Example: --lossless (This will enable lossless compression).
  25. --chroma-subsamplingDescription: Sets chroma subsampling, which affects color accuracy and compression.4:2:0: Compresses color information (better file size, less color detail).4:4:4: No color compression (higher quality).Default: "4:4:4" (No chroma subsampling for better quality).Example: --chroma-subsampling 4:2:0 (To use more compression).
  26. Description: Sets chroma subsampling, which affects color accuracy and compression.4:2:0: Compresses color information (better file size, less color detail).4:4:4: No color compression (higher quality).
  27. 4:2:0: Compresses color information (better file size, less color detail).
  28. 4:4:4: No color compression (higher quality).
  29. Default: "4:4:4" (No chroma subsampling for better quality).
  30. Example: --chroma-subsampling 4:2:0 (To use more compression).
  31. --keep-metadataDescription: Keeps all image metadata (e.g., EXIF, ICC, XMP, IPTC), such as camera settings and location data.Type: Boolean (true or false).Default: false (Metadata is stripped to save space).Example: --keep-metadata (Preserves metadata).
  32. Description: Keeps all image metadata (e.g., EXIF, ICC, XMP, IPTC), such as camera settings and location data.
  33. Type: Boolean (true or false).
  34. Default: false (Metadata is stripped to save space).
  35. Example: --keep-metadata (Preserves metadata).
  36. --overwriteDescription: Allows existing output files with the same name to be overwritten.Type: Boolean (true or false).Default: false (Existing files will not be overwritten).Example: --overwrite (Enables overwriting of existing files).
  37. Description: Allows existing output files with the same name to be overwritten.
  38. Type: Boolean (true or false).
  39. Default: false (Existing files will not be overwritten).
  40. Example: --overwrite (Enables overwriting of existing files).
  41. --append-extDescription: Appends .avif to the file name instead of replacing the current extension. For example, image.jpg will become image.jpg.avif.Type: Boolean (true or false).Default: false (The original file extension is replaced).Example: --append-ext (Keeps the original file name with .avif appended).
  42. Description: Appends .avif to the file name instead of replacing the current extension. For example, image.jpg will become image.jpg.avif.
  43. Type: Boolean (true or false).
  44. Default: false (The original file extension is replaced).
  45. Example: --append-ext (Keeps the original file name with .avif appended).
  46. --verboseDescription: Displays detailed progress information in the terminal as the files are processed.Type: Boolean (true or false).Default: false (Progress is not displayed).Example: -v-erbose (Shows detailed progress during conversion).
  47. Description: Displays detailed progress information in the terminal as the files are processed.
  48. Type: Boolean (true or false).
  49. Default: false (Progress is not displayed).
  50. Example: -v-erbose (Shows detailed progress during conversion).
  51. h, --helpDescription: Displays help information about the commands and options available.Type: Boolean (true or false).Usage: h or --help to display usage instructions.
  52. Description: Displays help information about the commands and options available.
  53. Type: Boolean (true or false).
  54. Usage: h or --help to display usage instructions.
  55. --versionDescription: Displays the current version of avif-cli.Type: Boolean (true or false).Usage: --version to see which version of the tool you are using.
  56. Description: Displays the current version of avif-cli.
  57. Type: Boolean (true or false).
  58. Usage: --version to see which version of the tool you are using.

Example Command:

If you want to convert all .png files in the current directory to .avif format with a quality of 80, save them in an output directory, and keep metadata, you would use:

npx avif *.png --quality 80 --output ./output-folder --keep-metadata

This will:

  • Convert all .png images.
  • Set quality to 80.
  • Save converted files to ./output-folder.EX output folder: /Users/caseylewis/Downloads/SEO Audit/edited
  • EX output folder: /Users/caseylewis/Downloads/SEO Audit/edited
  • Keep all metadata from the original files.

Conclusion

Converting your images to AVIF before uploading them to Webflow is a simple, effective way to improve the performance of your website.

By using the terminal, you can skip the hassle and cost of online converters, making your workflow faster and more efficient. With AVIF's superior compression and quality, your blog posts will load quicker, providing a better experience for your readers.

Give this method a try, and see how easy it is to integrate into your content creation process. Your audience—and your page speed—will thank you!

marketing health check clipboard showing score

Your Marketing Isn't Bringing in Leads and You Can't Figure Out Why

Score your marketing across 7 key areas in 5 minutes and find out exactly what's holding back your leads and what to fix first.

Questions You Might Be Asking

In most cases AVIF files are noticeably smaller than WebP at the same visual quality, sometimes by 30% or more on photographic content. WebP still has slightly broader browser support historically, but every modern browser supports AVIF now. For new projects, AVIF is the stronger default; keep WebP as a fallback only if you need to support very old clients.

Quality 50–60 is usually indistinguishable from the original for photos, and it produces much smaller files than WebP or JPEG at the same visual level. Go up to 70–80 for hero images or photography where detail matters. For screenshots and UI mockups where text sharpness is critical, try 80–90 or consider the lossless flag.

Yes. Higher effort values spend more CPU searching for smaller encodings, which can shave 10–20% off the final file size. The tradeoff is processing time — effort 9 can take several times longer than the default 4. For a one-time batch of blog images it's worth running at 7 or 8. For bulk jobs you care more about speed.

All current versions of Chrome, Firefox, Safari, and Edge support AVIF natively, so the vast majority of visitors will see them just fine. Users on very old browsers may not, though — if that's a concern for your audience, serve AVIF through a picture element with a WebP or JPEG fallback so the browser picks whatever it supports.

Stop losing deals to a website that's holding you back.

Book a 30-minute strategy session. You'll leave with a clearer picture of what your site needs to do and a rough budget range, whether you hire us or not.

background cta image collage of websites

Other posts in this category

A code editor showing JSON-LD schema markup next to a rendered search result with rich snippets

What Is Schema Markup and Why It Matters for AI Search

Schema markup is a labeling system that helps AI tools read your website with confidence. Here's what it is, what it can't do, and where to start.

A checklist on a clipboard next to a laptop showing an AI chat interface answering a business recommendation question

How do I know if my website is AI-ready? (An AI visibility checklist)

A practical 10-point checklist to test whether ChatGPT, Perplexity, and Google's AI results can find, understand, and recommend your business.

Map of the Dallas-Fort Worth metroplex with a magnifying glass focused on Ellis County local search results

Dallas SEO vs Local SEO

Competing for "Dallas" keywords means fighting hundreds of businesses for searchers who may be 45 minutes away. Here's when metro-wide SEO makes sense, and when owning your own backyard wins.