simple_magick 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +45 -1
- data/lib/simple_magick.rb +9 -17
- data/lib/simple_magick/image_magick.rb +62 -0
- data/lib/simple_magick/version.rb +1 -1
- data/simple_magick.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84cec9598f800ccc7f0fdde507e3e4bbf6d7f016
|
4
|
+
data.tar.gz: 332b6a270e80603d51a87e32350f92d59a963bdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdc31d9e883b830815eb7aea1ad211b63e274d58d6617895340aa3bf2297ae49ea74c0f6e5d66296a4d85eb7febbeaa460195b0b6ba9f7ec02925a94c3fc66fd
|
7
|
+
data.tar.gz: 2caf687984ace41542c206c90368bed7bb6bd29d539c7c9da03ef7702ea6c1d22920fb5ef0c13c667b8049770e6fa72e79f2ab8a2a9bec72fb3a86a34fa4d792
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1 +1,45 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
desc 'generate SimpleMagick DATA of mogrify option'
|
5
|
+
task :generate_option do |t|
|
6
|
+
version_string = `mogrify -version`
|
7
|
+
version_line = version_string.split("\n").first
|
8
|
+
version_line =~ /\AVersion:\s(.+\s.+\s.+\s.+\s)/
|
9
|
+
version = $1
|
10
|
+
|
11
|
+
options_string = `mogrify`
|
12
|
+
options = options_string.split("\n").map { |line|
|
13
|
+
if line.strip =~ /\A-(\w.+?)\s/
|
14
|
+
$1
|
15
|
+
end
|
16
|
+
}.compact.sort
|
17
|
+
|
18
|
+
image_magick = ''
|
19
|
+
image_magick << <<EOS
|
20
|
+
module SimpleMagick
|
21
|
+
|
22
|
+
# Don't manually modified!! (generate by $ rake generate_option)
|
23
|
+
# Generate Date #{Time.now}
|
24
|
+
# ImageMagick Version: #{version}
|
25
|
+
module ImageMagick
|
26
|
+
EXEC = 'mogrify'
|
27
|
+
|
28
|
+
OPTIONS = %w(
|
29
|
+
EOS
|
30
|
+
options.each_slice(5) do |opt|
|
31
|
+
image_magick << opt.join(' ')
|
32
|
+
image_magick << "\n"
|
33
|
+
end
|
34
|
+
image_magick << <<EOS
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
EOS
|
39
|
+
|
40
|
+
image_magick_path = Pathname(__dir__).join('lib', 'simple_magick', 'image_magick.rb').expand_path
|
41
|
+
File.open(image_magick_path, 'w') do |file|
|
42
|
+
file.puts image_magick
|
43
|
+
end
|
44
|
+
puts "Generate File ImageMagick Options. (#{image_magick_path})"
|
45
|
+
end
|
data/lib/simple_magick.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'simple_magick/version'
|
2
|
+
require 'simple_magick/image_magick'
|
2
3
|
require 'fileutils'
|
3
4
|
require 'open3'
|
4
5
|
require 'shellwords'
|
@@ -10,7 +11,7 @@ module SimpleMagick
|
|
10
11
|
# @note Windows Not Supported
|
11
12
|
# @return [Boolean] find mogrify command is true
|
12
13
|
def self.imagemagick_installed?
|
13
|
-
!`which
|
14
|
+
!`which #{ImageMagick::EXEC}`.split("\n").first.nil?
|
14
15
|
end
|
15
16
|
|
16
17
|
# Convert Image Class.
|
@@ -25,22 +26,13 @@ module SimpleMagick
|
|
25
26
|
def initialize(source_path, verbose = false)
|
26
27
|
@source_path = source_path
|
27
28
|
@verbose = verbose
|
28
|
-
@command = [
|
29
|
+
@command = [ImageMagick::EXEC]
|
29
30
|
end
|
30
31
|
|
31
|
-
#
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# @param [String] num image quality
|
37
|
-
def quality(num)
|
38
|
-
@command << "-quality #{command_escape(num)}"
|
39
|
-
end
|
40
|
-
|
41
|
-
# @param [String] string define string.
|
42
|
-
def define(string)
|
43
|
-
@command << "-define #{command_escape(string)}"
|
32
|
+
# set option
|
33
|
+
def method_missing(method, *args)
|
34
|
+
super unless ImageMagick::OPTIONS.include? method.to_s
|
35
|
+
__send__(:additional_option, method.to_s, args[0])
|
44
36
|
end
|
45
37
|
|
46
38
|
# use other options.
|
@@ -63,11 +55,11 @@ module SimpleMagick
|
|
63
55
|
puts "[INFO] #{command}" if @verbose
|
64
56
|
stdout, stderr, status = Open3.capture3(command)
|
65
57
|
rescue SystemCallError => e
|
66
|
-
raise ConvertError.new("
|
58
|
+
raise ConvertError.new("#{ImageMagick::EXEC} error. exec command => [#{command}], Error Detail => [#{e.message}]")
|
67
59
|
end
|
68
60
|
|
69
61
|
unless status.success?
|
70
|
-
raise ConvertError.new("
|
62
|
+
raise ConvertError.new("#{ImageMagick::EXEC} error. exec command => [#{command}], stdout => [#{stdout}], stderr => [#{stderr}]")
|
71
63
|
end
|
72
64
|
end
|
73
65
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module SimpleMagick
|
2
|
+
|
3
|
+
# Don't manually modified!! (generate by $ rake generate_option)
|
4
|
+
# Generate Date 2014-03-11 23:34:56 +0900
|
5
|
+
# ImageMagick Version: ImageMagick 6.8.7-7 Q16 x86_64 2013-11-27
|
6
|
+
module ImageMagick
|
7
|
+
EXEC = 'mogrify'
|
8
|
+
|
9
|
+
OPTIONS = %w(
|
10
|
+
adaptive-blur adaptive-resize adaptive-sharpen adjoin affine
|
11
|
+
affinity alpha alpha annotate antialias
|
12
|
+
append attenuate authenticate auto-gamma auto-level
|
13
|
+
auto-orient background bench bias black-threshold
|
14
|
+
blue-primary blue-shift blur border bordercolor
|
15
|
+
bordercolor brightness-contrast caption cdl cdl
|
16
|
+
channel charcoal chop clamp clip
|
17
|
+
clip-mask clip-path clut coalesce color-matrix
|
18
|
+
colorize colors colorspace combine comment
|
19
|
+
compare complex compose composite compress
|
20
|
+
contrast contrast-stretch convolve crop cycle
|
21
|
+
debug decipher decipher deconstruct define
|
22
|
+
delay delete density depth deskew
|
23
|
+
despeckle direction display dispose distort
|
24
|
+
distribute-cache dither draw duplicate edge
|
25
|
+
emboss encipher encipher encoding endian
|
26
|
+
enhance equalize evaluate evaluate-sequence extent
|
27
|
+
extract family features features fft
|
28
|
+
fill filter flatten flatten flip
|
29
|
+
floodfill flop font format frame
|
30
|
+
function function fuzz fx gamma
|
31
|
+
gaussian-blur geometry gravity grayscale green-primary
|
32
|
+
hald-clut help help identify ift
|
33
|
+
implode insert intensity intent interlace
|
34
|
+
interline-spacing interpolate interword-spacing kerning label
|
35
|
+
lat layers layers level level-colors
|
36
|
+
limit linear-stretch liquid-rescale list log
|
37
|
+
loop magnify mask matte mattecolor
|
38
|
+
median mode modulate monitor monochrome
|
39
|
+
morph morphology morphology mosaic motion-blur
|
40
|
+
negate noise normalize opaque ordered-dither
|
41
|
+
orient page paint path perceptible
|
42
|
+
ping pointsize polaroid poly posterize
|
43
|
+
precision preview print process profile
|
44
|
+
quality quantize quiet radial-blur raise
|
45
|
+
random-threshold red-primary regard-warnings region remap
|
46
|
+
render repage resample resize respect-parentheses
|
47
|
+
reverse roll rotate sample sampling-factor
|
48
|
+
scale scene seed segment selective-blur
|
49
|
+
separate sepia-tone set shade shadow
|
50
|
+
sharpen shave shear sigmoidal-contrast size
|
51
|
+
sketch smush solarize sparse-color splice
|
52
|
+
spread statistic stretch strip stroke
|
53
|
+
strokewidth style swap swirl synchronize
|
54
|
+
taint texture threshold thumbnail tile
|
55
|
+
tile-offset tint transform transparent transparent-color
|
56
|
+
transpose transverse treedepth trim type
|
57
|
+
undercolor unique-colors units unsharp verbose
|
58
|
+
version view vignette virtual-pixel wave
|
59
|
+
weight white-point white-threshold write
|
60
|
+
)
|
61
|
+
end
|
62
|
+
end
|
data/simple_magick.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sugamasao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Simple ImageMagick Wrapper.
|
84
98
|
email:
|
85
99
|
- sugamasao@gmail.com
|
@@ -96,6 +110,7 @@ files:
|
|
96
110
|
- benchmark/Gemfile
|
97
111
|
- benchmark/benchmark.rb
|
98
112
|
- lib/simple_magick.rb
|
113
|
+
- lib/simple_magick/image_magick.rb
|
99
114
|
- lib/simple_magick/version.rb
|
100
115
|
- simple_magick.gemspec
|
101
116
|
- spec/assets/sample.jpg
|