Code Monkey home page Code Monkey logo

ires's Introduction

Ires

Gem Version

Ires is image resizer gem.

Usage

View

<!-- Usually -->
<%= ires_tag(path: "image_01.jpg", width: 90, height: 120) %>

<!-- Using image_tag options -->
<%= ires_tag(path: "http://example.com/image_02.jpg", width: 200, height: 200, Ires::Mode::CROP, alt: "example image") %>

Get resize path

Ires::Service.path(path: '<FULL IMAGE PATH>', width: 400, height: 300)
=> /ires/<resize image path>

Select mode

info    mode    
Resize Ires::Mode::RESIZE (default)
Cropping Ires::Mode::CROP
Rsize after Cropping Ires::Mode::RESIZE_TO_CROP

Select type

Filter of resize image.

info    type    
All Ires::Type::ALL (default)
Smaller than Ires::Type::SMALLER
Larger than Ires::Type::LARGER

Specify cache expiration

Default: 30days

<%= ires_tag(path: '/image.jpg', width: 400, height: 300, expire: 7.days) %>

Saved directory

Target image is local

public
├── image.jpg
└── ires
    ├── crop
    │   ├── 20171019_image_120x90_crop.jpg
    │   ├── 20171117_image_200x200_crop.jpg
    │   └── 20171117_image_400x300_crop.jpg
    ├── resize
    │   ├── 20171019_image_120x90_resize.jpg
    │   ├── 20171117_image_200x200_resize.jpg
    │   └── 20171117_image_400x300_resize.jpg
    └── resize_to_crop
        ├── 20171019_image_120x90_resize_to_crop.jpg
        ├── 20171117_image_200x200_resize_to_crop.jpg
        └── 20171117_image_400x300_resize_to_crop.jpg

Target image is http

Parse URL & Create directory by parse URL.

Installation

Add this line to your application's Gemfile:

gem 'ires'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ires

Caution

  • It works only with linux and darwin now.
  • Can build only linux(.so)in this docker.

Development

Docker environment.

$ docker build -t ires:v1 .

# Into the ires container.
$ docker run -it -v $(pwd):/go/src/github.com/endotakuya/ires -p 3000:3000 ires:v1 /bin/bash

Gem test

Working in ires container.

1. Go(Create a shared object)

Package manager is dep.

# Dependent resolution
$ dep ensure

# Output to a shared object.
$ CGO_ENABLED=1 GOOS=linux go build -v -buildmode=c-shared -o shared/linux/ires.so ext/main.go

※ In the current Docker, you can build only linux environment. ※ If you want to build in other environments, add GCC or install Go on the host side.🙇

2. Start rails server

$ test/dummy/bin/rails s -b 0.0.0.0

License

The gem is available as open source under the terms of the MIT License.

ires's People

Contributors

endotakuya avatar

Watchers

Yoshiki.Kobayashi avatar James Cloos 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.