# -*- coding: utf-8 -*-
"""
Created on Mon Aug 12 09:51:34 2024

@author: Fajia Sun
"""

from PIL import Image
import pillow_avif

#you should first run `pip install pillow-avif-plugin`

#AVIF to JPEG
AVIFfilename = 'panda.avif'
AVIFimg = Image.open(AVIFfilename)
AVIFimg.save(AVIFfilename.replace("avif",'jpg'),'JPEG')
#can also to PNG

#other format to AVIF
JPGfilename = 'figure.jpg'
JPGimg = Image.open(JPGfilename)
JPGimg.save(JPGfilename.replace("jpg",'avif'),'AVIF')