Effortless image manipulation with a shell-pipe approach.
Project details
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.
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.
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.
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
In benchmarking tests, photu demonstrated superior speed compared to ImageMagick when processing public-domain images from the Met Museum's Open Access collection:
| Tool | Time |
|---|---|
| photu | 2.0 s |
ImageMagick Q8 with -define jpeg:size=1600x1200 | 12.6 s |
| ImageMagick Q8 | 22.2 s |
| ImageMagick Q16-HDRI | 23.0 s |
read command supports both local files and URLs, seamlessly integrating online images into the processing chain without overhead.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.
Comments
0Start the conversation
Share the first comment.