Skip to content

Instantly share code, notes, and snippets.

@johnie
Created August 13, 2024 17:19
Show Gist options
  • Save johnie/d50bf399171416a251bcacc2eabf05ec to your computer and use it in GitHub Desktop.
Save johnie/d50bf399171416a251bcacc2eabf05ec to your computer and use it in GitHub Desktop.
Automatically create a PNG copy of WEBP image

WEBP to PNG Converter

This Automator workflow automatically creates PNG copies of WEBP images in your Downloads and Pictures folders.

Features

  • Watches Downloads and Pictures folders for WEBP files
  • Automatically creates a PNG copy of each WEBP file
  • Keeps the original WEBP file intact
  • Uses built-in macOS sips command for conversion

Setup

  1. Open Automator and create a new workflow
  2. Choose "Folder Action" as the type
  3. Select both Downloads and Pictures folders to watch
  4. Add a "Run AppleScript" action
  5. Paste the provided script into the action
  6. Save the workflow

Requirements

  • macOS (comes with sips command pre-installed)

Note

This script creates copies. Your storage space may fill up faster if you receive many WEBP files.

Support

For issues or improvements, please contact the script author.

This README provides a concise overview of the WEBP to PNG converter script. It includes:

  1. A brief description of what the script does
  2. Key features
  3. Setup instructions
  4. System requirements
  5. A note about potential storage implications
  6. A brief mention of support

This README should give users a quick understanding of the script's purpose and how to set it up. It's intentionally kept short and to the point, as requested.

Would you like me to modify or expand on any part of this README?​​​​​​​​​​​​​​​​

-- This script watches the Downloads and Pictures folders for .webp files.
-- When a .webp file is detected, it creates a .png copy using the sips command,
-- keeping the original .webp file. Use this in an Automator Folder Action workflow.
on run {input, parameters}
set watchedFolders to {(path to downloads folder), (path to pictures folder)}
repeat with aFolder in watchedFolders
tell application "System Events"
set folderItems to files of aFolder whose name extension is "webp"
repeat with anItem in folderItems
set webpPath to POSIX path of (anItem as alias)
set pngPath to text 1 thru -6 of webpPath & ".png"
do shell script "/usr/local/bin/sips -s format png " & quoted form of webpPath & " --out " & quoted form of pngPath
end repeat
end tell
end repeat
return input
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment