littlecms 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in littlecms.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Carl Mercier
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,52 @@
1
+ # LittleCMS-Ruby
2
+
3
+ Simple Ruby wrapper for LittleCMS and jpegicc
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'littlecms'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install littlecms
18
+
19
+ ## Requirements
20
+
21
+ LittleCMS-Ruby requires the command `jpegicc` to be installed.
22
+
23
+ On Ubuntu/Debian:
24
+
25
+ $ apt-get install liblcms-utils
26
+
27
+ On Mac/Homebrew:
28
+
29
+ $ brew install little-cms
30
+
31
+ Other platforms: <http://www.littlecms.com/download.html>
32
+
33
+
34
+ ## Usage
35
+
36
+ require 'littlecms'
37
+ LittleCMS.jpegicc 'input.jpg'
38
+
39
+ # specify output
40
+ LittleCMS.jpegicc 'input.jpg', :output_path => 'output.jpg'
41
+
42
+ # add any option you want as described here: http://linux.die.net/man/1/jpegicc
43
+ LittleCMS.jpegicc 'input.jpg', :q => 80, :b => true, :c => 1
44
+
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,41 @@
1
+ require 'littlecms/version'
2
+ require 'fileutils'
3
+
4
+ class LittleCMS
5
+ def self.jpegicc(input_path, options = {})
6
+ output_path = options[:output_path] || input_path + ".out"
7
+ output_same_as_input = options[:output_path].nil?
8
+ executable_path = options[:executable_path] || "jpegicc"
9
+
10
+ raise ArgumentError.new("File not found: #{input_path}") unless File.exist?(input_path)
11
+
12
+ arguments = []
13
+ arguments << "-q#{options[:quality]}" if options[:quality]
14
+
15
+ %w(c h i m p o q t).each do |opt|
16
+ opt = opt.to_sym
17
+ next if options[:quality] && opt == :q
18
+ arguments << "-#{opt}#{options[opt]}" if options[opt]
19
+ end
20
+
21
+ %w(b g n v).each do |opt|
22
+ arguments << "-#{opt}" if options[opt.to_sym]
23
+ end
24
+
25
+ arguments = nil unless arguments.size > 0
26
+ command = [ executable_path, arguments, input_path, output_path ].compact
27
+
28
+ cmd_result = `#{command.join(' ')}`
29
+ exit_code = $?
30
+
31
+ if $? == 0
32
+ if output_same_as_input
33
+ FileUtils.cp output_path, input_path
34
+ FileUtils.rm output_path
35
+ end
36
+ true
37
+ else
38
+ false
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Littlecms
2
+ VERSION = "0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/littlecms/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Carl Mercier"]
6
+ gem.email = ["carl@carlmercier.com"]
7
+ gem.description = %q{Simple Ruby wrapper for LittleCMS and jpegicc}
8
+ gem.summary = %q{Simple Ruby wrapper for LittleCMS and jpegicc}
9
+ gem.homepage = "http://github.com/cmer/littlecms-ruby"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "littlecms"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Littlecms::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: littlecms
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Carl Mercier
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Simple Ruby wrapper for LittleCMS and jpegicc
15
+ email:
16
+ - carl@carlmercier.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - lib/littlecms.rb
27
+ - lib/littlecms/version.rb
28
+ - littlecms.gemspec
29
+ homepage: http://github.com/cmer/littlecms-ruby
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.23
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: Simple Ruby wrapper for LittleCMS and jpegicc
53
+ test_files: []