Converting images

14 May 2024

While JPG and PNG were once the most dominant image file formats, there are now lots of new options including AVIF and WebP. ThemeIsle did a comparison of AVIF and WebP. Their conclusion was that AVIF is better for compression without side-effects, but WebP is more widely adopted.

In this article I'll touch on how I work with the different files.

Converting DNG files

DNG files are a bit harder to work with. On Ubuntu I use darktable to convert them to JPG-files with their CLI tool.
darktable-cli inputfile.dng outputfile.jpg
Simple as that. Even keeps the EXIF data.
find . -type f \( -iname "*.dng" \) -exec sh -c 'darktable-cli {} ${0%.*}.jpg' {} \; -delete

How I work with AVIF files

https://web.dev/compress-images-avif/ https://stackoverflow.com/questions/65765174/convert-png-images-to-lossy-avif

Converting AVIF to PNG

pip3 install pillow-avif-plugin
from PIL import Image
import pillow_avif

img = Image.open('input.avif')
img.save('output.png')

Converting PNG to AVIF

convert image.png image.avif

How I work with WebP files

Converting to WebP

cwebp input.jpg -o output.webp

Converting from WebP to PNG

dwebp input.webp -o output.png

You might also enjoy

Useful Laravel packages

Useful Laravel packages

Published 2024-05-05

Laravel

PHP

Web development

Learn what packages that can help you build even better websites in Laravel. We'll go trhough the must-haves and packages that are just nice to have.

Read the post →
Using Python to organize your media files

Using Python to organize your media files

Published 2024-04-26

Python

Sorting media files can be a hassle, because no two devices have the same naming convention. Using Python I rename a bunch of files based on their media info.

Read the post →
Lenovo Yoga wifi adapter not working on Ubuntu

Lenovo Yoga wifi adapter not working on Ubuntu

Published 2024-04-26

Bug fixes

Learn how to fix the wifi adapter on a Lenovo Yoga 7 running Ubuntu.

Read the post →