tootsie 0.9.24 → 0.9.25

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -88,6 +88,7 @@ Video jobs have the `type` key set to either `video`, `audio`. Currently, `audio
88
88
  * `height`: desired video frame height in pixels.
89
89
  * `format`: File format.
90
90
  * `content_type`: Content type of resultant file. Tootsie will not be able to guess this at the moment.
91
+ * `strip_metadata`: If true, metadata such as ID3 will be deleted. Since recent ffmpeg versions have issues with ID3 tags and character encodings, this is recommended for audio files. Requires `id3v2` tool.
91
92
 
92
93
  Completion notification provides the following data:
93
94
 
@@ -188,6 +189,7 @@ Requirements
188
189
  For video jobs:
189
190
 
190
191
  * FFmpeg
192
+ * id3v2 (optional)
191
193
 
192
194
  For image jobs:
193
195
 
@@ -24,6 +24,7 @@ module Tootsie
24
24
  case @url
25
25
  when /^file:(.*)/
26
26
  FileUtils.cp(@temp_file.path, $1)
27
+ @result_url = @url
27
28
  when /^s3:.*/
28
29
  s3_options = S3Utilities.parse_uri(@url)
29
30
  bucket_name, path = s3_options[:bucket], s3_options[:key]
@@ -41,19 +41,26 @@ module Tootsie
41
41
  original_type = nil
42
42
  original_format = nil
43
43
  original_orientation = nil
44
- CommandRunner.new("identify -format '%z %w %h %r %m %[EXIF:Orientation]' :file").
44
+ CommandRunner.new("identify -format '%z %w %h %m %[EXIF:Orientation] %r' :file").
45
45
  run(:file => input.file_name) do |line|
46
- if line =~ /(\d+) (\d+) (\d+) ([^\s]+) ([^\s]+) (\d+)?/
46
+ if line =~ /(\d+) (\d+) (\d+) ([^\s]+) (\d+)? (.+)/
47
47
  original_depth, original_width, original_height = $~[1, 3].map(&:to_i)
48
- original_type = $4
49
- original_format = $5.downcase
50
- original_orientation = $6.try(:to_i)
48
+ original_format = $4.downcase
49
+ original_orientation = $5.try(:to_i)
50
+ original_type = $6
51
51
  end
52
52
  end
53
53
  unless original_width and original_height
54
54
  raise "Unable to determine dimensions of input image"
55
55
  end
56
56
 
57
+ if (output_format = version_options[:format])
58
+ # Sanitize format so we can use it in file name
59
+ output_format = output_format.to_s
60
+ output_format.gsub!(/[^\w]/, '')
61
+ end
62
+ output_format ||= original_format
63
+
57
64
  # Correct for EXIF orientation
58
65
  if [5, 6, 7, 8].include?(original_orientation)
59
66
  original_width, original_height = original_height, original_width
@@ -101,19 +108,24 @@ module Tootsie
101
108
  end
102
109
 
103
110
  convert_command = "convert"
104
- convert_options = {:input_file => input.file_name}
105
- case version_options[:format]
106
- when 'png', 'jpeg', 'gif'
107
- convert_options[:output_file] = "#{version_options[:format]}:#{output.file_name}"
108
- else
109
- convert_options[:output_file] = output.file_name
111
+ convert_options = {
112
+ :input_file => input.file_name,
113
+ :output_file => "'#{output_format}:#{output.file_name}'"
114
+ }
115
+
116
+ # Animations may contain more than one fram, if so discard the
117
+ # extra frames when outputting in a non-animation format
118
+ if original_format == 'gif' and version_options[:format] != 'gif'
119
+ flags << ' -flatten -scene 1'
110
120
  end
121
+
111
122
  if scale != :none
112
123
  convert_command << " -resize :resize"
113
124
  convert_options[:resize] = "#{scale_width}x#{scale_height}"
114
125
  end
115
126
  if version_options[:crop]
116
127
  convert_command << " -gravity center -crop :crop"
128
+ convert_command << " +repage" # This fixes some animations
117
129
  convert_options[:crop] = "#{new_width}x#{new_height}+0+0"
118
130
  end
119
131
  if version_options[:strip_metadata]
@@ -123,16 +135,18 @@ module Tootsie
123
135
 
124
136
  convert_command << " -quality #{((version_options[:quality] || 1.0) * 100).ceil}%"
125
137
 
126
- # Work around a problem with ImageMagick being too clever and "optimizing"
127
- # the bit depth of RGB images that contain a single grayscale channel.
128
- # Coincidentally, this avoids ImageMagick rewriting the ICC data and
129
- # corrupting it in the process.
130
- if original_type =~ /(?:Gray|RGB)(Matte)?$/ and original_format != 'png'
131
- convert_command << " -type TrueColor#{$1}"
138
+ if original_format =~ /^(jpeg|tiff)$/i
139
+ # Work around a problem with ImageMagick being too clever and "optimizing"
140
+ # the bit depth of RGB images that contain a single grayscale channel.
141
+ # Coincidentally, this avoids ImageMagick rewriting the ICC data and
142
+ # corrupting it in the process.
143
+ if original_type =~ /(?:Gray|RGB)(Matte)?$/
144
+ convert_command << " -type TrueColor#{$1}"
145
+ end
132
146
  end
133
147
 
134
148
  # Fix CMYK images
135
- if medium == :web and original_type =~ /CMYK$/
149
+ if medium == :web and original_type =~ /CMYK/
136
150
  convert_command << " -colorspace rgb"
137
151
  end
138
152
 
@@ -10,6 +10,7 @@ module Tootsie
10
10
  @thumbnail_options = (params[:thumbnail] || {}).with_indifferent_access
11
11
  @versions = [params[:versions] || {}].flatten
12
12
  @thread_count = Application.get.configuration.ffmpeg_thread_count
13
+ @logger = Application.get.logger
13
14
  end
14
15
 
15
16
  def valid?
@@ -41,6 +42,15 @@ module Tootsie
41
42
  begin
42
43
  output = Output.new(version_options[:target_url])
43
44
  begin
45
+ if version_options[:strip_metadata]
46
+ # This actually strips in-place, so no need to swap streams
47
+ CommandRunner.new("id3v2 --delete-all '#{input.file_name}'").run do |line|
48
+ if line.present? and line !~ /\AStripping id3 tag in.*stripped\./
49
+ @logger.warn "ID3 stripping failed, ignoring: #{line}"
50
+ end
51
+ end
52
+ end
53
+
44
54
  adapter_options = version_options.dup
45
55
  adapter_options.delete(:target_url)
46
56
  if thumbnail_output
@@ -1,3 +1,3 @@
1
1
  module Tootsie
2
- VERSION = '0.9.24'
2
+ VERSION = '0.9.25'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tootsie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.24
4
+ version: 0.9.25
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-03-05 00:00:00.000000000Z
12
+ date: 2012-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70200855862880 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 1.6.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70200855862880
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.6.5
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: sinatra
27
- requirement: &70200855862160 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '1.0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70200855862160
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: activesupport
38
- requirement: &70200855861400 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 3.0.0
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70200855861400
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: httpclient
49
- requirement: &70200855860680 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 2.2.1
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *70200855860680
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.2.1
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: builder
60
- requirement: &70200855859940 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: 2.1.2
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *70200855859940
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 2.1.2
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: mime-types
71
- requirement: &70200855859100 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: '1.16'
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *70200855859100
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '1.16'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: xml-simple
82
- requirement: &70200855857940 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ~>
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: 1.0.12
88
118
  type: :runtime
89
119
  prerelease: false
90
- version_requirements: *70200855857940
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.0.12
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: thin
93
- requirement: &70200855856900 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ~>
@@ -98,10 +133,15 @@ dependencies:
98
133
  version: 1.2.7
99
134
  type: :runtime
100
135
  prerelease: false
101
- version_requirements: *70200855856900
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 1.2.7
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: s3
104
- requirement: &70200855856180 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
105
145
  none: false
106
146
  requirements:
107
147
  - - ~>
@@ -109,10 +149,15 @@ dependencies:
109
149
  version: 0.3.8
110
150
  type: :runtime
111
151
  prerelease: false
112
- version_requirements: *70200855856180
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 0.3.8
113
158
  - !ruby/object:Gem::Dependency
114
159
  name: bunny
115
- requirement: &70200855855340 !ruby/object:Gem::Requirement
160
+ requirement: !ruby/object:Gem::Requirement
116
161
  none: false
117
162
  requirements:
118
163
  - - ~>
@@ -120,10 +165,15 @@ dependencies:
120
165
  version: 0.7.8
121
166
  type: :runtime
122
167
  prerelease: false
123
- version_requirements: *70200855855340
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 0.7.8
124
174
  - !ruby/object:Gem::Dependency
125
175
  name: sqs
126
- requirement: &70200855854420 !ruby/object:Gem::Requirement
176
+ requirement: !ruby/object:Gem::Requirement
127
177
  none: false
128
178
  requirements:
129
179
  - - ~>
@@ -131,10 +181,15 @@ dependencies:
131
181
  version: 0.1.2
132
182
  type: :runtime
133
183
  prerelease: false
134
- version_requirements: *70200855854420
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ~>
188
+ - !ruby/object:Gem::Version
189
+ version: 0.1.2
135
190
  - !ruby/object:Gem::Dependency
136
191
  name: unicorn
137
- requirement: &70200855853620 !ruby/object:Gem::Requirement
192
+ requirement: !ruby/object:Gem::Requirement
138
193
  none: false
139
194
  requirements:
140
195
  - - ~>
@@ -142,10 +197,15 @@ dependencies:
142
197
  version: 4.1.1
143
198
  type: :runtime
144
199
  prerelease: false
145
- version_requirements: *70200855853620
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ~>
204
+ - !ruby/object:Gem::Version
205
+ version: 4.1.1
146
206
  - !ruby/object:Gem::Dependency
147
207
  name: i18n
148
- requirement: &70200855852720 !ruby/object:Gem::Requirement
208
+ requirement: !ruby/object:Gem::Requirement
149
209
  none: false
150
210
  requirements:
151
211
  - - ! '>='
@@ -153,10 +213,15 @@ dependencies:
153
213
  version: 0.4.2
154
214
  type: :runtime
155
215
  prerelease: false
156
- version_requirements: *70200855852720
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: 0.4.2
157
222
  - !ruby/object:Gem::Dependency
158
223
  name: scashin133-syslog_logger
159
- requirement: &70200855851700 !ruby/object:Gem::Requirement
224
+ requirement: !ruby/object:Gem::Requirement
160
225
  none: false
161
226
  requirements:
162
227
  - - ~>
@@ -164,10 +229,15 @@ dependencies:
164
229
  version: 1.7.3
165
230
  type: :runtime
166
231
  prerelease: false
167
- version_requirements: *70200855851700
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ~>
236
+ - !ruby/object:Gem::Version
237
+ version: 1.7.3
168
238
  - !ruby/object:Gem::Dependency
169
239
  name: rspec
170
- requirement: &70200855851120 !ruby/object:Gem::Requirement
240
+ requirement: !ruby/object:Gem::Requirement
171
241
  none: false
172
242
  requirements:
173
243
  - - ! '>='
@@ -175,10 +245,15 @@ dependencies:
175
245
  version: '0'
176
246
  type: :development
177
247
  prerelease: false
178
- version_requirements: *70200855851120
248
+ version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ! '>='
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
179
254
  - !ruby/object:Gem::Dependency
180
255
  name: rake
181
- requirement: &70200855850520 !ruby/object:Gem::Requirement
256
+ requirement: !ruby/object:Gem::Requirement
182
257
  none: false
183
258
  requirements:
184
259
  - - ! '>='
@@ -186,7 +261,12 @@ dependencies:
186
261
  version: '0'
187
262
  type: :development
188
263
  prerelease: false
189
- version_requirements: *70200855850520
264
+ version_requirements: !ruby/object:Gem::Requirement
265
+ none: false
266
+ requirements:
267
+ - - ! '>='
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
190
270
  description: Tootsie is a simple audio/video/image transcoding/modification application.
191
271
  email:
192
272
  - alex@origo.no
@@ -244,15 +324,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
244
324
  - - ! '>='
245
325
  - !ruby/object:Gem::Version
246
326
  version: '0'
327
+ segments:
328
+ - 0
329
+ hash: -4405205189496115955
247
330
  required_rubygems_version: !ruby/object:Gem::Requirement
248
331
  none: false
249
332
  requirements:
250
333
  - - ! '>='
251
334
  - !ruby/object:Gem::Version
252
335
  version: '0'
336
+ segments:
337
+ - 0
338
+ hash: -4405205189496115955
253
339
  requirements: []
254
340
  rubyforge_project: tootsie
255
- rubygems_version: 1.8.15
341
+ rubygems_version: 1.8.24
256
342
  signing_key:
257
343
  specification_version: 3
258
344
  summary: Tootsie is a simple audio/video/image transcoding/modification application.