npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

image-video-optimizer

v3.4.0

Published

CLI tool to optimize and compress images and videos with configurable settings

Downloads

2,531

Readme

Image Video Optimizer

A powerful CLI tool to optimize images, videos, audio, and PDFs with configurable resize and compression settings.

Features

  • Image Optimization: Resize and convert images to specified formats
  • Video Optimization: Resize videos and encode to specified formats
  • Audio Optimization: Convert and compress audio files to MP3
  • PDF Compression: Compress PDF files using Ghostscript
  • Resume Support: Track processed files and resume interrupted sessions
  • Configurable Settings: Use .image-video-optimizer.conf files for custom settings
  • Smart Compression: Only keeps optimized files if compression is effective (>1%)
  • Recursive Search: Finds all media files in subdirectories
  • Detailed Logging: Shows processing progress and summary statistics

Installation

npm install -g image-video-optimizer

Usage

Basic Usage

image-video-optimizer . # will proceed the current directory
image-video-optimizer /path/to/directory # will proceed the specified directory
image-video-optimizer /path/to/directory/file.jpg # will proceed the specified image file
image-video-optimizer /path/to/directory/file.pdf # will proceed the specified pdf file
image-video-optimizer /path/to/directory/file.mp4 # will proceed the specified video file
image-video-optimizer /path/to/directory/file.mp3 # will proceed the specified audio file

Options

image-video-optimizer /path/to/directory [options]
  • <target>: Target directory or file to optimize (required)
  • -r, --reset: Reset status file and start fresh
  • -v, --verbose: Enable verbose logging
  • -V, --version: Show version number
  • -h, --help: Show help

Configuration

Create a .image-video-optimizer.conf file in your target directory to customize settings:

# Image settings
img_max_width=1080          # Maximum width for images (pixels)
img_format=jpg              # Target format for image conversion

# Video settings
video_max_width=720         # Maximum width for videos (pixels)
video_encode=h264           # Video encoding format

# Audio settings
audio_ext=mp3              # Audio extension for audio files

# PDF settings
pdf_compress=true           # Enable/disable PDF compression

Default Configuration

If no configuration file is found, these defaults are used:

  • img_max_width: 1080
  • img_format: jpg
  • video_max_width: 720
  • video_encode: h264
  • audio_ext: mp3
  • pdf_compress: true

Supported Formats

Images

  • Input: jpg, jpeg, png, gif, bmp, tiff, webp
  • Output: jpg, png, webp (configurable)

Videos

  • Input: avi, mov, wmv, flv, webm, mkv, m4v, mp4
  • Output: mp4 (with configurable encoding)

Audio

  • Input: mp3, wav, flac, aac, ogg, m4a
  • Output: mp3 (configurable)

Documents

  • Input: pdf
  • Output: pdf (compressed)

Processing Logic

Image Processing

  1. Searches for image files recursively
  2. Checks if image width exceeds img_max_width
  3. Resizes if necessary while maintaining aspect ratio
  4. Converts to target format if different
  5. Compares file sizes and keeps optimized version only if compression > 1%

Video Processing

  1. Searches for video files recursively
  2. Checks if video width exceeds video_max_width
  3. Resizes if necessary while maintaining aspect ratio
  4. Encodes to target format (default: H.264)
  5. Converts to MP4 format
  6. Compares file sizes and keeps optimized version only if compression > 1%

Audio Processing

  1. Searches for audio files recursively
  2. Converts to target format (default: MP3)
  3. Applies aggressive compression (single channel, 16kHz, 32k bitrate)
  4. Replaces original with compressed version

PDF Processing

  1. Searches for PDF files recursively
  2. Uses Ghostscript to compress PDFs
  3. Falls back to copy if Ghostscript is not available
  4. Replaces original with compressed version

Resume Logic

  1. Creates .image-video-optimizer-status.json to track processed files
  2. Skips already processed files on subsequent runs
  3. Updates status file after each file is processed
  4. Use --reset to clear status and start fresh

Examples

Optimize a directory with default settings

image-video-optimizer ./photos

Reset status and start fresh

image-video-optimizer ./photos --reset

Verbose output

image-video-optimizer ./photos --verbose

Custom configuration

Create .image-video-optimizer.conf:

img_max_width=1920
img_format=webp
video_max_width=1080
video_encode=h265
audio_ext=mp3
pdf_compress=true

Then run:

image-video-optimizer . # and image-video-optimizer the same as it will proceed the current directory
image-video-optimizer ./media/path/to/directory # will proceed the specified directory

Dependencies

System Requirements

  • Node.js >= 14.0.0
  • FFmpeg (for video and audio processing)
  • Ghostscript (for PDF compression, optional)

Installing Requirements

Arch/GopiOS:

sudo pacman -Syu ffmpeg x264

Ubuntu/Debian:

sudo apt install ffmpeg ghostscript

macOS:

brew install ffmpeg ghostscript

License

nirvána