imageproxy 0.4.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,8 +41,9 @@ Feel free to help out with some of these :)
41
41
  * nice error messages for improper API use
42
42
  * performance
43
43
 
44
+ See also the [release notes](https://github.com/eahanson/imageproxy/blob/master/release-notes.mdown)
44
45
 
45
- PERFORMANCE
46
+ Performance
46
47
  -----------
47
48
 
48
49
  imageproxy doesn't do any sort of caching. That kind of thing is better left up to CDNs (like Amazon CloudFront or VoxCast CDN) or to caching proxies such as Varnish.
@@ -50,7 +51,7 @@ imageproxy doesn't do any sort of caching. That kind of thing is better left up
50
51
  Also, imageproxy itself isn't nearly as fast as it could be. It's written in an interpreted language, and it shells out to curl and ImageMagick to do its work. Presumably, it would be way faster written in C as an Apache module or something.
51
52
 
52
53
 
53
- REQUIREMENTS
54
+ Requirements
54
55
  ------------
55
56
 
56
57
  * [Ruby](http://www.ruby-lang.org/)
@@ -59,7 +60,7 @@ REQUIREMENTS
59
60
  * [Curl](http://curl.haxx.se)
60
61
 
61
62
 
62
- INSTALLING
63
+ Installing
63
64
  ----------
64
65
 
65
66
  gem install imageproxy
@@ -169,6 +170,9 @@ Example Ruby code to generate the signature:
169
170
 
170
171
  `IMAGEPROXY_MAX_SIZE` The maximum dimension allowed for a `resize` or `thumbnail` operation. Specifying `20` would cause a resize of `10x30` to fail because the maximum dimension of `20` is less than the largest requested dimension of `30`.
171
172
 
173
+ `IMAGEPROXY_WORLD_READABLE_TEMPFILE` set to `true` if you want the generated tempfiles to be `-rw-r--r--` instead of the default `-rw-------`
174
+
175
+
172
176
  ### Obfuscating Requests
173
177
 
174
178
  You may obfuscate your requests by Base64 encoding and then URL encoding your query string or path. The parameter name for this encoded value is `_` if you're using a query string or `-` if you're using a path. Example:
@@ -316,6 +320,12 @@ To run the specs
316
320
 
317
321
  rake spec
318
322
 
323
+ Related
324
+ -------
325
+
326
+ * [Thumbor](https://github.com/globocom/thumbor) is similar but has "smart crop" using various detection algorithms and some other features.
327
+
328
+
319
329
  Thanks
320
330
  ------
321
331
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 1.0.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "imageproxy"
8
- s.version = "0.4.3"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Erik Hanson"]
12
- s.date = "2012-11-26"
12
+ s.date = "2013-02-23"
13
13
  s.description = "A image processing proxy server, written in Ruby as a Rack application. Requires ImageMagick."
14
14
  s.email = "erik@eahanson.com"
15
15
  s.extra_rdoc_files = [
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
39
39
  "public/background.png",
40
40
  "public/sample.png",
41
41
  "public/sample_10x20.png",
42
+ "release-notes.mdown",
42
43
  "spec/command_spec.rb",
43
44
  "spec/convert_spec.rb",
44
45
  "spec/identify_format_spec.rb",
@@ -1,11 +1,14 @@
1
1
  require File.join(File.expand_path(File.dirname(__FILE__)), "command")
2
+ require "timeout"
2
3
 
3
4
  module Imageproxy
4
5
  class Convert < Imageproxy::Command
5
6
  attr_reader :options
6
7
 
7
- def initialize(options)
8
+ def initialize(options, settings={})
8
9
  @options = options
10
+ @settings = settings
11
+
9
12
  if (!(options.resize || options.thumbnail || options.rotate || options.flip || options.format ||
10
13
  options.quality || options.overlay))
11
14
  raise "Missing action or illegal parameter value"
@@ -83,9 +86,14 @@ module Imageproxy
83
86
  def new_format
84
87
  options.format ? "#{options.format}:" : ""
85
88
  end
86
-
89
+
87
90
  def file
88
- @tempfile ||= Tempfile.new("imageproxy").tap(&:close)
91
+ @tempfile ||= begin
92
+ file = Tempfile.new("imageproxy")
93
+ file.chmod 0644 if @settings[:world_readable_tempfile]
94
+ file.close
95
+ file
96
+ end
89
97
  end
90
98
  end
91
- end
99
+ end
@@ -51,7 +51,9 @@ module Imageproxy
51
51
  private
52
52
 
53
53
  def convert_file(options, user_agent)
54
- Convert.new(options).execute(user_agent, config(:timeout))
54
+ Convert.
55
+ new(options, world_readable_tempfile: config?(:world_readable_tempfile)).
56
+ execute(user_agent, config(:timeout))
55
57
  end
56
58
 
57
59
  def config(symbol)
@@ -122,4 +124,4 @@ module Imageproxy
122
124
  Imageproxy::IdentifyFormat.new(file).execute
123
125
  end
124
126
  end
125
- end
127
+ end
@@ -0,0 +1,47 @@
1
+ Imageproxy Release Notes
2
+ ========================
3
+
4
+ See the [Imageproxy readme](https://github.com/eahanson/imageproxy/blob/master/README.mdown) for more info.
5
+
6
+ ### 1.0 - February 22, 2013
7
+
8
+ * Bumped version to 1.0 -- imageproxy has been in production for over 1.5 years at this point and deserves a real version number
9
+ * Added `world_readable_tempfile` option to make the permissions of the generated tempfiles to be `-rw-r--r--` instead of the default `-rw-------`
10
+
11
+ ### 0.4.3 - November 26, 2012
12
+
13
+ * Fix error on Heroku Cedar (thanks Daniel Szmulewicz!)
14
+ * Retry `curl` command after 10 second timeout
15
+
16
+ ### 0.4.2 - August 8, 2012
17
+
18
+ * Have `curl` report errors to standard error
19
+
20
+ ### 0.4.1 - July 24, 2012
21
+
22
+ * Improve logging on errors
23
+
24
+ ### 0.4.0 - May 16, 2012
25
+
26
+ * Add ability to composite two images
27
+
28
+ ### 0.3.0 - May 15, 2012
29
+
30
+ * Allow '.' characters in base 64-encoded path, which gets replaced with '=' characters before decoding
31
+
32
+ ### 0.2.0 - August 28, 2011
33
+
34
+ * When a command fails, only raise an exception in Ruby 1.9, not 1.8
35
+
36
+ ### 0.1.4 - August 24, 2011
37
+
38
+ * Add timeout option
39
+
40
+ ### 0.1.3 - June 9, 2011
41
+
42
+ * Use ImageMagick's `identify` command to figure out the content type of the image
43
+ * Follow redirects when requesting images
44
+
45
+ ### 0.1.0 - June 8, 2011
46
+
47
+ * Initial version
@@ -32,6 +32,18 @@ describe Imageproxy::Convert do
32
32
  end
33
33
  end
34
34
 
35
+ describe "#file" do
36
+ it "should create a world-readable tempfile if requested" do
37
+ convert = Imageproxy::Convert.new(
38
+ Imageproxy::Options.new("", {:resize=> "20x20", :source => "http%3A%2F%2Fexample.com%2Fdog.jpg"}),
39
+ world_readable_tempfile: true)
40
+ mock_file = mock("Tempfile", close: nil, path: "")
41
+ mock_file.should_receive(:chmod).with(0644)
42
+ Tempfile.should_receive(:new).and_return(mock_file)
43
+ convert.file
44
+ end
45
+ end
46
+
35
47
  context "when resizing" do
36
48
  it("with no extra args") do
37
49
  command(:resize => "10x20").convert_options.should ==
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imageproxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-26 00:00:00.000000000 Z
12
+ date: 2013-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -186,6 +186,7 @@ files:
186
186
  - public/background.png
187
187
  - public/sample.png
188
188
  - public/sample_10x20.png
189
+ - release-notes.mdown
189
190
  - spec/command_spec.rb
190
191
  - spec/convert_spec.rb
191
192
  - spec/identify_format_spec.rb
@@ -208,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
209
  version: '0'
209
210
  segments:
210
211
  - 0
211
- hash: 1087416563410215419
212
+ hash: 3085346647419398487
212
213
  required_rubygems_version: !ruby/object:Gem::Requirement
213
214
  none: false
214
215
  requirements: