streamio-magick 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,20 +3,18 @@
3
3
  # Error example:
4
4
  # identify: no decode delegate for this image format `file.ext' @ error/constitute.c/ReadImage/532.
5
5
 
6
+ require 'shellwords'
7
+
6
8
  class Magick::Image
7
9
  attr_reader :width, :height, :codec, :path, :size
8
10
 
9
11
  def initialize(path)
10
12
  raise Errno::ENOENT, "the file '#{path}' does not exist" unless File.exists?(path)
11
13
 
12
- @path = escape(path)
14
+ @path = path
13
15
  @size = File.size(path)
14
16
 
15
- stdin, stdout, stderr = Open3.popen3("identify '#{path}'") # Output will land in stderr
16
-
17
- out = stdout.read
18
- err = stderr.read
19
-
17
+ out = Open3.popen3("identify #{Shellwords.escape(path)}") { |stdin, stdout, stderr| stdout.read }
20
18
  @valid = out.length > 0
21
19
 
22
20
  if valid?
@@ -32,19 +30,10 @@ class Magick::Image
32
30
  end
33
31
 
34
32
  def transcode(output_file, parameters = "")
35
- stdin, stdout, stderr = Open3.popen3("convert #{path} #{escape(parameters)} #{output_file}")
36
-
37
- out = stdout.read
38
- err = stderr.read
33
+ err = Open3.popen3("convert #{Shellwords.escape(path)} #{parameters} #{Shellwords.escape(output_file)}") { |stdin, stdout, stderr| stderr.read }
39
34
 
40
35
  raise Magick::Error, err if err.length > 0
41
36
 
42
37
  self.class.new(output_file)
43
38
  end
44
-
45
- protected
46
- def escape(path)
47
- map = { '\\' => '\\\\', '</' => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"' }
48
- path.gsub(/(\\|<\/|\r\n|[\n\r"])/) { map[$1] }
49
- end
50
39
  end
@@ -1,3 +1,3 @@
1
1
  module Magick
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: streamio-magick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-04 00:00:00.000000000 Z
12
+ date: 2012-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70345206698120 !ruby/object:Gem::Requirement
16
+ requirement: &70355088347620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.2
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70345206698120
24
+ version_requirements: *70355088347620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70345206697540 !ruby/object:Gem::Requirement
27
+ requirement: &70355088346940 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '2.9'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70345206697540
35
+ version_requirements: *70355088346940
36
36
  description: Simple yet powerful wrapper around imagemagick cli tools for reading
37
37
  metadata and transcoding images.
38
38
  email:
@@ -61,7 +61,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  segments:
63
63
  - 0
64
- hash: 4072242714818656611
64
+ hash: 857626735448748048
65
65
  required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  none: false
67
67
  requirements: