Socket
Book a DemoInstallSign in
Socket

image_optim_rake

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image_optim_rake

0.0.4
bundlerRubygems
Version published
Maintainers
1
Created
Source

image_optim_rake

Gem Version Build Status Code Climate

A simple wrapper around image_optim to batch minify all images in one or more directories.

Designed to work with Rails and per default recursively looks for JPGs and PNGs in app\assets\images and public.

Installation

Add this line to your application's Gemfile:

gem 'image_optim_rake'

And then execute:

$ bundle

Or install it yourself as:

$ gem install image_optim_rake

Binary installation

As above mentions this gem uses image_optim, which itself relies on some binary tools. These must be present at the system, but pngout is disabled here per default.

Linux - Debian/Ubuntu

sudo apt-get install -y advancecomp gifsicle jpegoptim libjpeg-progs optipng pngcrush

Linux - RHEL/Fedora/Centos

sudo yum install -y advancecomp gifsicle libjpeg optipng

You will also need to install jpegoptim and pngcrush from source:

jpegoptim

cd /tmp
curl -O http://www.kokkonen.net/tjko/src/jpegoptim-1.2.4.tar.gz
tar zxf jpegoptim-1.2.4.tar.gz
cd jpegoptim-1.2.4
./configure && make && make install

pngcrush

cd /tmp
curl -O http://iweb.dl.sourceforge.net/project/pmt/pngcrush/1.7.43/pngcrush-1.7.43.tar.gz
tar zxf pngcrush-1.7.43.tar.gz
cd pngcrush-1.7.43
make && cp -f pngcrush /usr/local/bin

OS X: Macports

sudo port install advancecomp gifsicle jpegoptim jpeg optipng pngcrush

OS X: Brew

brew install advancecomp gifsicle jpegoptim jpeg optipng pngcrush

pngout installation (optional)

You can install pngout by downloading and installing the binary versions.

Note: pngout is free to use even in commercial soft, but you can not redistribute, repackage or reuse it without consent and agreement of creator. license

Copied from: https://github.com/toy/image_optim/

Usage

Change to your project directory and run:

$ rake image_optim:minify

You can define the directories where images will be searched recursively by setting a dirs argument:

$ rake image_optim:minify dirs=app/assets/images,public,lib/assets/images,vendor/assets/images

Configuration

You can modify the configuration which is passed to image_optim:

ImageOptimRake::ImageOptimTask.config = {
    :threads => true,
    :pngout  => false
}

You can also modify the default paths:

ImageOptimTask.dirs   = ["app/assets/images", "public"]

A good place would be an initializer in a Rails environment.

Test

$ rake test

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Added some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 01 Jul 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.