Skip to content
Back to skills

Convert Png To Webp

ASecurity

Use this skill when converting PNG images in a directory tree to lossless WebP in place with `cwebp`, preserving original file timestamps, deleting the source PNG files only after successful conversion, and reporting the processed image count.

  • 4 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 12, 2026
toolspythonbash

Works with

  • cli

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 12, 2026

npx -y skills add aibot88/sec_skill_store --skill convert-png-to-webp --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Convert Png To Webp?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Convert Png To Webp
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aibot88-convert-png-to-webp/badge)](https://www.skillsdirectory.com/skills/aibot88-convert-png-to-webp)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: convert-png-to-webp
description: "Use this skill when converting PNG images in a directory tree to lossless WebP in place with `cwebp`, preserving original file timestamps, deleting the source PNG files only after successful conversion, and reporting the processed image count."
license: MIT
metadata:
  author: cssmagic
---

# Convert PNG to WebP

## Purpose

Convert PNG files inside one directory tree to same-location `.webp` files:

- Convert PNG files to lossless WebP.
- Preserve original modification time and, on macOS, creation time.
- Delete each source PNG only after its WebP replacement is complete.
- Report how many PNG files were processed.



## Required Input

Each run needs one directory to process.

If the directory is missing or ambiguous, ask the user for the path before running commands.

Normalize `~` and relative paths to an absolute path before reporting or running the script.



## Defaults

Treat PNG extensions case-insensitively.

Map each PNG to a same-directory, same-basename `.webp` file.

Do not overwrite existing `.webp` files unless the user explicitly allows overwrite behavior. If a mapped `.webp` already exists, report the exact PNG and WebP paths and stop before converting anything.

Reject symlinked PNG files before writing, because deleting a symlink after conversion is easy to misread.



## Prerequisites

Use the official WebP CLI:

```bash
command -v cwebp
```

The bundled script requires Python 3:

```bash
command -v python3
```

On macOS, creation-time preservation requires:

```bash
command -v GetFileInfo
command -v SetFile
```

If those macOS timestamp tools are unavailable, stop before converting anything.



## Workflow

Set the directory from the user's provided path:

```bash
dir="/absolute/path/to/directory"
```

Run the bundled script from this skill directory:

```bash
python3 scripts/convert_png_to_webp.py "$dir"
```

Only pass `--overwrite` if the user explicitly permits replacing existing mapped WebP files:

```bash
python3 scripts/convert_png_to_webp.py --overwrite "$dir"
```

The script performs preflight checks before writing:

- required commands
- directory existence
- existing mapped WebP files
- target path collisions, including case-insensitive collisions
- symlinked PNG files

During conversion, the script writes a temporary WebP beside the source file, syncs timestamps, atomically moves it into place, and only then deletes the source PNG.



## Reporting

Summarize with:

- directory
- PNG files found
- converted WebP files
- deleted original PNG files
- failed files, if any
- timestamp failure count
- whether macOS creation times were synced

Files in this skill

  • SKILL.md2.6 KB
  • source.json775 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.