image_size.cr
Get the image dimension (width and height) of various image types.
Supported types:
- through
stb_image.h
: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC - through
libwebp
: WebP
Installation
- Add the dependency to your
shard.yml
:
dependencies:
image_size:
github: hkalexling/image_size.cr
- Run
shards install
Usage
require "image_size"
# Using the path to the image file
size = ImageSize.get "test.png"
pp size.width
pp size.height
# Using binary data
file = File.new "test.png"
bytes = Bytes.new file.size
file.read bytes
file.close
size = ImageSize.get bytes
pp size.width
pp size.height
Contributors
- Alex Ling - creator and maintainer