Batch image compressor
Skill congemcd/skills-collection/skills/batch-image-compressor
npx -y skills add congemcd/skills-collection --skill batch-image-compressorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Compress JPEG and PNG images in a directory without changing resolution or format using jpegoptim and pngquant. Use when the user wants to reduce image file sizes in a directory.
SKILL.md
2.4 KB, as published. Nobody here has run it
Batch Image Compressor
This skill compresses JPEG and PNG images in a directory without changing their resolution or format. It uses jpegoptim and pngquant CLI tools to achieve high compression with excellent quality preservation. pngquant provides massive file size reductions for PNGs by intelligently reducing the number of colors while keeping visual differences nearly imperceptible.
Workflow
- Check Dependencies: Before doing anything else, check if
jpegoptimandpngquantare installed by runningwhich jpegoptimandwhich pngquant. If either tool is missing, explicitly explain to the user why they are needed (to perform the high-quality, resolution-preserving compression) and directly execute the command to install them via Homebrew (brew install jpegoptim pngquant). Do not wait for the user to do it manually. - Analyze Directory: Locate all
.jpg,.jpeg, and.pngfiles in the target directory (defaulting to the current working directory). Calculate the total size of these images before compression. Inform the user how many images were found and the total starting size. - Determine Naming/Overwrite Rules: Do NOT directly compress and overwrite original images unless the user explicitly states to do so. If the user does not specify a naming rule, create new images and add a "compressed-" prefix to their filenames (e.g.,
compressed-image.jpg). If the user does not specify an output directory, output the new compressed images in the same directory as the original images. - Compress JPEGs: For each
.jpgand.jpegfile found:- If preserving originals, copy the file first (e.g.,
cp "img.jpg" "compressed-img.jpg") and then executejpegoptim -m80 --strip-all "compressed-img.jpg". - If overwriting, execute
jpegoptim -m80 --strip-all "<file>".
- If preserving originals, copy the file first (e.g.,
- Compress PNGs: For each
.pngfile found:- If preserving originals, execute
pngquant --output "compressed-img.png" "img.png". - If overwriting, execute
pngquant --ext .png --force "<file>".
- If preserving originals, execute
- Summary Report: After all images are processed, calculate the new total size of the compressed images. Report the original total size, the new total size, and the total space saved in a concise summary.