Compress and optimize PNG, JPEG, WebP, and AVIF images with the TinyPNG/Tinify HTTP API using only curl and the TINYPNG_API_KEY environment variable. Use when Codex needs to shrink image files, optionally resize them, convert formats, or preserve metadata, especially when the user asks to compress an image with TinyPNG or Tinify.
Use this skill to compress local image files through the TinyPNG/Tinify HTTP API without installing SDKs or extra packages. Use the bundled shell script on macOS/Linux and the PowerShell script on Windows.
TINYPNG_API_KEY is set in the current environment.scripts/tinypng.sh on macOS/Linux or scripts/tinypng.ps1 on Windows.--input for default compression.--width, --height, --convert, or --preserve only when the user explicitly asks for those operations.--output is omitted.Default behavior:
--convert is provided.--width or --height is provided.--preserveResize behavior:
--width and --height are provided, the script uses TinyPNG's fit resize mode.scale resize mode because the HTTP API requires that for single-dimension resizing.Natural-language examples:
Explicit skill examples:
$tinypng to compress hero.png."$tinypng to compress photo.jpg and set width to 128."$tinypng to convert banner.png to WebP."Shell examples:
export TINYPNG_API_KEY="your-api-key"
./scripts/tinypng.sh --input ./hero.png
./scripts/tinypng.sh --input ./hero.png --width 128
./scripts/tinypng.sh --input ./banner.png --width 128 --height 128
./scripts/tinypng.sh --input ./banner.png --convert webp
./scripts/tinypng.sh --input ./photo.jpg --preserve creation,location
./scripts/tinypng.sh --input ./hero.png --output ./hero-optimized.png
PowerShell examples:
$env:TINYPNG_API_KEY = "your-api-key"
powershell -ExecutionPolicy Bypass -File .\scripts\tinypng.ps1 --input .\hero.png
powershell -ExecutionPolicy Bypass -File .\scripts\tinypng.ps1 --input .\hero.png --width 128
powershell -ExecutionPolicy Bypass -File .\scripts\tinypng.ps1 --input .\banner.png --width 128 --height 128
powershell -ExecutionPolicy Bypass -File .\scripts\tinypng.ps1 --input .\banner.png --convert webp
powershell -ExecutionPolicy Bypass -File .\scripts\tinypng.ps1 --input .\photo.jpg --preserve creation,location
powershell -ExecutionPolicy Bypass -File .\scripts\tinypng.ps1 --input .\hero.png --output .\hero-optimized.png
Script entrypoints:
scripts/tinypng.shscripts/tinypng.ps1Supported flags:
--input <file>--output <file>--width <n>--height <n>--convert <webp|avif|jpeg|png>--preserve <copyright,creation,location>--helpOutput naming:
--output is omitted, the script writes a sibling file with .tinypng inserted before the extension.--convert is provided and --output is omitted, the generated file extension matches the requested format.curl to be available in the environment.TINYPNG_API_KEY.