PitchHut logo
Effortless image manipulation with a shell-pipe approach.
Pitch

Photu simplifies batch image processing by allowing users to create efficient pipelines using standard shell commands. With a focus on speed and low memory usage, photu combines multiple image operations into a single libvips command, streamlining workflows and reducing complexity in image handling.

Description

photu is a versatile command-line tool designed for efficient batch image processing. Leveraging the power of libvips, photu allows users to create sophisticated image manipulation pipelines using standard shell pipes, ultimately executing all operations in a single, high-performance libvips operation. This not only enhances speed but also optimizes memory usage.

Example Usage

photu read "photos/*.jpg" | photu resize 1600 | photu sharpen | photu write "out/{name}.webp" quality=80

In comparison, the corresponding ImageMagick command is more complex and prone to user error: magick mogrify -path out -format webp -quality 80 -resize 1600x1600\> -unsharp 0x1 photos/*.jpg. Photu (ફોટુ) draws its name from colloquial Gujarati slang for a photo, emphasizing its focus on images.

Users can explore photu directly in the browser at tryphotu.vercel.app, where the same parser and libvips are utilized in a WebAssembly environment, with images processed locally.

How It Works

Unlike traditional image processing tools where each operation might require separate processes and temporary files, photu manages operations through a JSON plan. Each command contributes to this plan without carrying the image data through the pipe. This means that regardless of how many steps are included in the pipeline, each image is decoded and encoded just once, enhancing performance. Users can inspect the current state of the processing plan using:

photu read "photos/*.jpg" | photu resize 800x600 fit=cover | photu explain

Performance

In benchmarking tests, photu demonstrated superior speed compared to ImageMagick when processing public-domain images from the Met Museum's Open Access collection:

ToolTime
photu2.0 s
ImageMagick Q8 with -define jpeg:size=1600x120012.6 s
ImageMagick Q822.2 s
ImageMagick Q16-HDRI23.0 s

Features

  • Chaining Operations: Photu allows an unlimited number of stages in a pipeline, enabling complex workflows for resizing, cropping, adjusting colors, and more in a streamlined manner.
  • Remote Image Handling: The read command supports both local files and URLs, seamlessly integrating online images into the processing chain without overhead.
  • Comprehensive Commands: Include features for reading files, resizing, cropping, rotating, overlaying watermarks, and adjusting colors. Each command has distinct options for tailoring the output precisely to user needs.
  • Format Support: Photu can read and write multiple formats, including JPEG, PNG, WebP, GIF, TIFF, and AVIF. Animated formats are processed frame-by-frame, maintaining the integrity of animations throughout the processing pipeline.

Error Handling

Photu emphasizes robustness by performing thorough input validation prior to any image processing. It catches errors related to malformed inputs, URL validation, and output filename conflicts before any actual pixel manipulation occurs.

Overall, photu merges simplicity with advanced processing capabilities, making it an invaluable tool for those seeking to optimize their image manipulation workflows.

0 comments

No comments yet.

Sign in to be the first to comment.