mozjpeg 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5c709616826cf24e650f7bb809a722d8da2c8591
4
+ data.tar.gz: 2368cb79b6bbd669b11fe9028a6b079d321cf2f3
5
+ SHA512:
6
+ metadata.gz: 168ff707986aade6c2f7ad1f633d13d6943de5a7458adfbdc264bb4d1fee2dc0cbf2f7fb5a53a12d72b2c9da7351ed7efea628ed49cd77bd6f57510fada8188f
7
+ data.tar.gz: 83a6c85119b2002401dc4eb3ca971de9f4e4eaa975dc495363dd8042a05c8f07abfd763106b0d162000d28cd0b522f376a31ac607921e1e473d9cbb05a415e91
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mozjpeg.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # About
2
+
3
+ This repository contains the ruby library for easy interaction with MozJPEG compressor, an improved JPEG encoder (based on cjpeg).
4
+
5
+ Binaries of [MozJPEG 3.0](https://boomswaggerboom.wordpress.com/2014/12/30/mozjpeg-3-0-released/) for Mac OS X (64bit), Linux (64bit) and Windows are included in this gem.
6
+
7
+ This gem was successfully tested on the following systems: (test for binaries included in the source)
8
+
9
+ * Mac OS X 10.10 - ruby 2.2.2
10
+ * Linux CentOS 6 - ruby 2.2.2
11
+ * Windows XP - ruby 2.0.0p645
12
+
13
+ Please report other systems that work, any problems or questions opening and issue on Github.
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'mozjpeg'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install mozjpeg
30
+
31
+ ## Usage
32
+
33
+ ```ruby
34
+ # check system support
35
+ Mozjpeg.supported? # true
36
+
37
+ # ask for location of (bundled) MozJPEG binary for current platform (Mac, Linux, Win)
38
+ Mozjpeg.cjpeg_path
39
+ # => /path/to/gems/bundled/cjpeg
40
+ # raises error if not supported
41
+
42
+ # compress JPEG file (accepts instances of `File`)
43
+ large_image = File.new('large.jpeg')
44
+ tiny_image = File.new('tiny.jpeg')
45
+
46
+ Mozjpeg.compress large_image, tiny_image
47
+
48
+ # to pass command line arguments to MozJPEG:
49
+ Mozjpeg.compress large_image, tiny_image, arguments: '-quality 70 -quant-table 2 -notrellis')
50
+
51
+ ```
52
+
53
+ ## [Paperclip](https://github.com/thoughtbot/paperclip)
54
+
55
+ This gem was made to be used with the `paperclip-mozjpeg` gem, which adds file processor to compress JPEG images uploaded using the [paperclip](https://github.com/thoughtbot/paperclip) gem.
56
+
57
+ ## License
58
+
59
+ This gem is licensed under the MIT license.
60
+ [MozJPEG license](https://github.com/mozilla/mozjpeg/blob/master/LICENSE.txt)
61
+ The included JPEG fixture photo for tests is licenced under Creative Commons - CC0.
62
+
63
+ ## Contributing
64
+
65
+ 1. Fork it ( https://github.com/svoboda-jan/mozjpeg-ruby/fork )
66
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
67
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
68
+ 4. Push to the branch (`git push origin my-new-feature`)
69
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "test/**/*_test.rb"
6
+ end
7
+
8
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mozjpeg"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/mozjpeg.rb ADDED
@@ -0,0 +1,35 @@
1
+ require "mozjpeg/version"
2
+ require 'os'
3
+
4
+ module Mozjpeg
5
+
6
+ def self.supported?
7
+ cjpeg_path rescue false
8
+ end
9
+
10
+ def self.cjpeg_path
11
+ base_path = File.expand_path(File.join(__dir__, '../vendor/mozjpeg'))
12
+
13
+ mozjpeg_path = begin
14
+ if OS.windows?
15
+ 'win/cjpeg.exe'
16
+ elsif OS.mac? && OS.bits == 64
17
+ 'darwin/cjpeg'
18
+ elsif OS.linux? && os.bits == 64
19
+ 'linux/cjpeg'
20
+ else
21
+ raise "MozJPEG for your platform was not found."
22
+ end
23
+ end
24
+
25
+ File.join(base_path, mozjpeg_path)
26
+ end
27
+
28
+ # TODO improve
29
+ # Accepts instances of File
30
+ def self.compress(src, dst, options = {})
31
+ args = options.fetch(:arguments, '-quality 70 -quant-table 2 -notrellis')
32
+ return `"#{Mozjpeg.cjpeg_path}" #{args} -outfile "#{dst.path}" "#{src.path}" 2>&1`
33
+ end
34
+
35
+ end
@@ -0,0 +1,3 @@
1
+ module Mozjpeg
2
+ VERSION = "0.0.1"
3
+ end
data/mozjpeg.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mozjpeg/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mozjpeg"
8
+ spec.version = Mozjpeg::VERSION
9
+ spec.authors = ["Jan Svoboda"]
10
+ spec.email = ["jan@mluv.cz"]
11
+
12
+ spec.summary = %q{JPEG and PNG compression using MozJPEG}
13
+ spec.description = %q{JPEG and PNG compression using MozJPEG, with included binaries.}
14
+ spec.homepage = "https://github.com/svoboda-jan/mozjpeg-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.required_ruby_version = ">= 1.9"
23
+
24
+ spec.add_development_dependency "bundler"
25
+ spec.add_development_dependency "rake"
26
+
27
+ spec.add_development_dependency "minitest", "~> 5.4.2"
28
+
29
+ spec.add_dependency "os", "~> 0.9.6"
30
+ end
@@ -0,0 +1,7 @@
1
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
2
+
3
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
4
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
5
+ * Neither the name of the mozjpeg Project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
6
+
7
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Binary file
Binary file
Binary file
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mozjpeg
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jan Svoboda
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 5.4.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 5.4.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: os
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.6
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.6
69
+ description: JPEG and PNG compression using MozJPEG, with included binaries.
70
+ email:
71
+ - jan@mluv.cz
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - README.md
80
+ - Rakefile
81
+ - bin/console
82
+ - bin/setup
83
+ - lib/mozjpeg.rb
84
+ - lib/mozjpeg/version.rb
85
+ - mozjpeg.gemspec
86
+ - vendor/mozjpeg/LICENSE.txt
87
+ - vendor/mozjpeg/darwin/cjpeg
88
+ - vendor/mozjpeg/darwin/libjpeg.62.dylib
89
+ - vendor/mozjpeg/darwin/libpng16.16.dylib
90
+ - vendor/mozjpeg/linux/cjpeg
91
+ - vendor/mozjpeg/linux/libjpeg.so.62
92
+ - vendor/mozjpeg/win/cjpeg.exe
93
+ - vendor/mozjpeg/win/libjpeg-62.dll
94
+ homepage: https://github.com/svoboda-jan/mozjpeg-ruby
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '1.9'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.4.6
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: JPEG and PNG compression using MozJPEG
118
+ test_files: []