Git Product home page Git Product logo

image_size.cr's Introduction

image_size.cr

CI

Get and modify the image dimension (width and height) of various image types.

Supported types:

Installation

  1. Add the dependency to your shard.yml:
dependencies:
 image_size:
   github: hkalexling/image_size.cr
  1. Run shards install

Usage

require "image_size"

# Get dimension from the path to the image file
size = ImageSize.get "test.png"
pp size.width
pp size.height

# Get dimension from 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

# Resize the image width to 1024. The height is automatically calculated
#	to keep the aspect ratio
bytes = ImageSize.resize "test.png", width: 1024
File.write "test-1024.png", bytes

# Resize the image height to 256. The width is automatically calculated
#	to keep the aspect ratio
bytes = ImageSize.resize "test.png", height: 256
File.write "test-256.png", bytes

# Resize the image dimension to 1024 x 1024
bytes = ImageSize.resize "test.png", width: 1024, height: 1024
File.write "test-1024-1024.png", bytes

Contributors

image_size.cr's People

Contributors

hkalexling avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.