Library that finds the dimensions and type of an image fetching as little as needed.
https://jetrockets.github.io/fastimage.cr
-
Add the dependency to your
shard.yml
:dependencies: fastimage: github:jetrockets/fastimage.cr
-
Run
shards install
require "fastimage"
Returns image type. Returns nil
if image type is not supported.
FastImage.type("https://file-examples.com/wp-content/uploads/2017/10/file_example_PNG_3MB.png")
# => png
Same as #type
, but raise exception if anything goes wrong.
Returns image width and height as a Tuple(UInt16?, UInt16?)
. Returns nil
if image type is not supported.
FastImage.dimensions("https://file-examples.com/wp-content/uploads/2017/10/file_example_PNG_3MB.png")
# => [2200, 1467]
Same as #dimensions
, but raise exception if anything goes wrong.
- Data sources
- Remote file
- HTTP/HTTPS
- Proxy
- HTTP redirects
- Local file
- IO
- Base64
- Remote file
- File formats
- BMP
- CUR
- GIF
- ICO
- JPEG
- parse EXIF information for JPEG orientation
- PNG
- PSD
- SVG
- TIFF
- WEBP
- Fork it (https://github.com/jetrockets/fastimage.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Igor Alexandrov - creator and maintainer