SuperAPI AI Directory

webp-to-jpg

Design & creation

View repository

Updated 10-16 08:45

About this skill

WebP to JPG Conversion Skill

Function Overview

This skill will help you convert WebP format images to JPG format so they can be used on platforms that do not support the WebP format.

Usage Scenarios

  • Use images on platforms that do not support the WebP format, such as WeChat Official Accounts
  • Convert WebP images to the more universal JPG format
  • Prepare an image format suitable for a specific platform

Conversion Steps

  1. Check the Pillow library: Confirm that the system has the Pillow library installed for image processing
    python -c "from PIL import Image; print('Pillow is available')"
    
  1. Install the Pillow library(if not installed):

    pip install Pillow
    
  2. Perform format conversion:

    from PIL import Image
    
    # 打开WebP图片
    img = Image.open('<webp_image_path>')
    
    # 转换为RGB模式(因为JPG不支持透明度)
    rgb_img = img.convert('RGB')
    
    # 保存为JPG格式
    rgb_img.save('<jpg_image_path>', 'JPEG')
    

Complete conversion command

Use the Python command line directly for conversion:

python -c "from PIL import Image; img = Image.open('<webp_image_path>'); rgb_img = img.convert('RGB'); rgb_img.save('<jpg_image_path>', 'JPEG'); print('图片转换成功')"

Replace <webp_image_path> with your WebP image path, and replace <jpg_image_path> with the JPG image path where you want to save it.

Notes

  • The JPG format does not support transparency, so the transparent parts of WebP will be converted to a white background
  • The image quality after conversion may change slightly
  • Make sure the target path has write permission