A Ruby gem that fetches image size and type from a URI by downloading only the minimal necessary data.
FastImage is a Ruby library that extracts image dimensions and file type from a URI or local file by fetching only the minimal amount of data required. It addresses the inefficiency of downloading entire images for metadata, offering significant speed improvements for web applications handling remote images. The tool supports a wide range of image formats and works without external dependencies like ImageMagick.
Ruby developers building web applications that need to process image attributes (e.g., for layout adjustments, HTML image tags, or asset management) from remote sources without incurring high bandwidth costs.
Developers choose FastImage for its exceptional performance in fetching image metadata with minimal network transfer, reducing latency and server load. Its pure Ruby implementation and lack of external dependencies make it easy to integrate and reliable for production use.
FastImage finds the size or type of an image given its uri by fetching as little as needed
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Downloads only the necessary bytes for metadata, drastically reducing transfer times; benchmarks show it can be over 10x faster than fetching entire files for formats like JPEG and PNG.
Works with 11 common image types including GIF, JPEG, PNG, TIFF, BMP, ICO, CUR, PSD, SVG, WEBP, and JXL, covering most web and design use cases.
Pure Ruby implementation eliminates the need for libraries like RMagick or ImageMagick, simplifying installation and reducing potential compatibility issues.
Accepts URIs, local file paths, and any object responding to :read (e.g., IO streams), making it adaptable for various data handling scenarios.
Supports proxies, timeouts, custom headers, up to 4 redirects, and Data URIs, enhancing usability in production web environments with complex networking needs.
For TIFF files where metadata isn't stored near the start, FastImage can be slower, as admitted in the benchmark section; alternatives like image_size handle this more efficiently.
Only extracts dimensions, file type, and Exif orientation; it cannot retrieve other attributes like color depth, compression details, or comprehensive EXIF data, limiting advanced image analysis.
Requires careful sanitization of input strings, as it will attempt to read from any passed value, posing a risk if unsanitized user input is used directly.
Requires Ruby 1.9.2 or later, which may hinder adoption in legacy systems running older Ruby versions without upgrades.