streamio-magick 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ Streamio Magick
2
+ ###############
3
+
4
+ Simple yet powerful wrapper around imagemagick cli tools for reading metadata and transcoding images.
5
+
6
+ Installation
7
+ ------------
8
+
9
+ (sudo) gem install streamio-magick
10
+
11
+ You also need to make sure to have imagemagick installed and that the commands identify and convert are available to the ruby process.
12
+
13
+ This version is written against an imagemagick build from august 2010. So no guaranteed compatability with much earlier (or much later) versions.
14
+
15
+ Usage
16
+ -----
17
+
18
+ ### Require the gem
19
+
20
+ ```ruby
21
+ require 'rubygems'
22
+ require 'streamio-magick'
23
+ ```
24
+
25
+ ### Reading Metadata
26
+
27
+ ```ruby
28
+ image = Magick::Image.new("path/to/image.png")
29
+
30
+ image.width # 640 (width of the image in pixels)
31
+ image.height # 480 (height of the image in pixels)
32
+ image.size # 455546 (filesize in bytes)
33
+ image.codec # "PNG"
34
+
35
+ image.valid? # true (would be false if identify fails to read the image)
36
+ ```
37
+
38
+ ### Transcoding
39
+
40
+ First argument is the output file path.
41
+
42
+ ```ruby
43
+ image.transcode("image.jpg") # Transcode to jpg format
44
+ ```
45
+
46
+ Give custom command line options for the convert command with a string.
47
+
48
+ ```ruby
49
+ image.transcode("image.jpg", "-resize 320x240")
50
+ ```
51
+
52
+ The transcode function returns an Image object for the encoded file.
53
+
54
+ ```ruby
55
+ transcoded_image = image.transcode("image.jpg", "-resize 320x240")
56
+ ```
57
+
58
+ ```ruby
59
+ transcoded_image.width # 320
60
+ transcoded_image.height # 240
61
+ transcoded_image.codec # "JPEG"
62
+ ```
63
+
64
+ Rescue from Magick::Error if something goes wrong during transcoding.
65
+
66
+ ```ruby
67
+ begin
68
+ image.transcode("image.jpg")
69
+ rescue Magick::Error => e
70
+ # handle error
71
+ end
72
+ ```
73
+
74
+ Copyright
75
+ ---------
76
+
77
+ Copyright (c) Streamio Networks AB. See LICENSE for details.
@@ -0,0 +1,4 @@
1
+ module Magick
2
+ class Error < Exception
3
+ end
4
+ end
data/lib/magick/image.rb CHANGED
@@ -37,7 +37,7 @@ class Magick::Image
37
37
  out = stdout.read
38
38
  err = stderr.read
39
39
 
40
- raise err if err.length > 0
40
+ raise Magick::Error, err if err.length > 0
41
41
 
42
42
  self.class.new(output_file)
43
43
  end
@@ -1,3 +1,3 @@
1
1
  module Magick
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'open3'
2
2
 
3
3
  require 'magick/version'
4
- require 'magick/image'
4
+ require 'magick/error'
5
+ require 'magick/image'
metadata CHANGED
@@ -1,89 +1,77 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: streamio-magick
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - David Backeus
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-08-26 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: rspec
12
+ date: 2012-04-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &70366275152940 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.2
22
+ type: :development
23
23
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: *70366275152940
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70366275152440 !ruby/object:Gem::Requirement
25
28
  none: false
26
- requirements:
27
- - - "="
28
- - !ruby/object:Gem::Version
29
- hash: 27
30
- segments:
31
- - 1
32
- - 3
33
- - 0
34
- version: 1.3.0
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '2.9'
35
33
  type: :development
36
- version_requirements: *id001
37
- description: Simple yet powerful wrapper around imagemagick cli tools for reading metadata and transcoding images.
38
- email:
34
+ prerelease: false
35
+ version_requirements: *70366275152440
36
+ description: Simple yet powerful wrapper around imagemagick cli tools for reading
37
+ metadata and transcoding images.
38
+ email:
39
39
  - david@streamio.se
40
40
  executables: []
41
-
42
41
  extensions: []
43
-
44
42
  extra_rdoc_files: []
45
-
46
- files:
43
+ files:
44
+ - lib/magick/error.rb
47
45
  - lib/magick/image.rb
48
46
  - lib/magick/version.rb
49
47
  - lib/streamio-magick.rb
50
- - README.rdoc
48
+ - README.md
51
49
  - LICENSE
52
- has_rdoc: true
53
50
  homepage: http://github.com/streamio/streamio-magick
54
51
  licenses: []
55
-
56
52
  post_install_message:
57
53
  rdoc_options: []
58
-
59
- require_paths:
54
+ require_paths:
60
55
  - lib
61
- required_ruby_version: !ruby/object:Gem::Requirement
56
+ required_ruby_version: !ruby/object:Gem::Requirement
62
57
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- hash: 3
67
- segments:
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ segments:
68
63
  - 0
69
- version: "0"
70
- required_rubygems_version: !ruby/object:Gem::Requirement
64
+ hash: 3378515517869724734
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
66
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 23
76
- segments:
77
- - 1
78
- - 3
79
- - 6
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
80
70
  version: 1.3.6
81
71
  requirements: []
82
-
83
72
  rubyforge_project:
84
- rubygems_version: 1.3.7
73
+ rubygems_version: 1.8.17
85
74
  signing_key:
86
75
  specification_version: 3
87
76
  summary: Reads metadata and transcodes images.
88
77
  test_files: []
89
-
data/README.rdoc DELETED
@@ -1,51 +0,0 @@
1
- = Streamio Magick
2
-
3
- Simple yet powerful wrapper around imagemagick cli tools for reading metadata and transcoding images.
4
-
5
- == Installation
6
-
7
- (sudo) gem install streamio-magick
8
-
9
- You also need to make sure to have imagemagick installed and that the commands identify and convert are available to the ruby process.
10
-
11
- This version is written against an imagemagick build from august 2010. So no guaranteed compatability with much earlier (or much later) versions.
12
-
13
- == Usage
14
-
15
- === Require the gem
16
-
17
- require 'rubygems'
18
- require 'streamio-magick'
19
-
20
- === Reading Metadata
21
-
22
- image = Magick::Image.new("path/to/image.png")
23
-
24
- image.width # 640 (width of the image in pixels)
25
- image.height # 480 (height of the image in pixels)
26
- image.size # 455546 (filesize in bytes)
27
- image.codec # "PNG"
28
-
29
- image.valid? # true (would be false if identify fails to read the image)
30
-
31
- === Transcoding
32
-
33
- First argument is the output file path.
34
-
35
- image.transcode("image.jpg") # Transcode to jpg format
36
-
37
- Give custom command line options for the convert command with a string.
38
-
39
- image.transcode("image.jpg", "-resize 320x240")
40
-
41
- The transcode function returns an Image object for the encoded file.
42
-
43
- transcoded_image = image.transcode("image.jpg", "-resize 320x240")
44
-
45
- transcoded_image.width # 320
46
- transcoded_image.height # 240
47
- transcoded_image.codec # "JPEG"
48
-
49
- == Copyright
50
-
51
- Copyright (c) 2010 Streamio Networks AB. See LICENSE for details.