image_vise 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -0
  3. data/.travis.yml +13 -0
  4. data/DEVELOPMENT.md +0 -11
  5. data/Gemfile +2 -20
  6. data/Rakefile +3 -26
  7. data/image_vise.gemspec +37 -132
  8. data/lib/image_vise/file_response.rb +2 -2
  9. data/lib/image_vise/image_request.rb +2 -0
  10. data/lib/image_vise/operators/background_fill.rb +18 -0
  11. data/lib/image_vise/operators/ellipse_stencil.rb +7 -5
  12. data/lib/image_vise/operators/force_jpg_out.rb +17 -0
  13. data/lib/image_vise/pipeline.rb +13 -3
  14. data/lib/image_vise/render_engine.rb +36 -64
  15. data/lib/image_vise/version.rb +3 -0
  16. data/lib/image_vise/writers/auto_writer.rb +23 -0
  17. data/lib/image_vise/writers/jpeg_writer.rb +9 -0
  18. data/lib/image_vise.rb +19 -19
  19. metadata +43 -135
  20. data/spec/image_vise/auto_orient_spec.rb +0 -10
  21. data/spec/image_vise/crop_spec.rb +0 -20
  22. data/spec/image_vise/ellipse_stencil_spec.rb +0 -19
  23. data/spec/image_vise/fetcher_file_spec.rb +0 -48
  24. data/spec/image_vise/fetcher_http_spec.rb +0 -44
  25. data/spec/image_vise/file_response_spec.rb +0 -45
  26. data/spec/image_vise/fit_crop_spec.rb +0 -20
  27. data/spec/image_vise/geom_spec.rb +0 -33
  28. data/spec/image_vise/image_request_spec.rb +0 -62
  29. data/spec/image_vise/pipeline_spec.rb +0 -72
  30. data/spec/image_vise/render_engine_spec.rb +0 -325
  31. data/spec/image_vise/sharpen_spec.rb +0 -17
  32. data/spec/image_vise/srgb_spec.rb +0 -28
  33. data/spec/image_vise/strip_metadata_spec.rb +0 -14
  34. data/spec/image_vise_spec.rb +0 -110
  35. data/spec/layers-with-blending.psd +0 -0
  36. data/spec/spec_helper.rb +0 -103
  37. data/spec/test_server.rb +0 -61
  38. data/spec/waterside_magic_hour.jpg +0 -0
  39. data/spec/waterside_magic_hour.psd +0 -0
  40. data/spec/waterside_magic_hour_adobergb.jpg +0 -0
  41. data/spec/waterside_magic_hour_gray.tif +0 -0
  42. data/spec/waterside_magic_hour_transp.png +0 -0
data/spec/spec_helper.rb DELETED
@@ -1,103 +0,0 @@
1
- require 'bundler'
2
- Bundler.require
3
-
4
- require 'addressable/uri'
5
- require 'strenv'
6
- require 'tmpdir'
7
- require_relative 'test_server'
8
-
9
-
10
- TEST_RENDERS_DIR = Dir.mktmpdir
11
-
12
- module Examine
13
- def examine_image(magick_image, name_tag = 'test-img')
14
- # When doing TDD, waiting for stuff to open is a drag - allow
15
- # it to be squelched using 2 envvars. Also viewing images
16
- # makes no sense on CI unless we bother with artifacts.
17
- # The first one is what Gitlab-CI sets for us.
18
- return if ENV.key?("CI_BUILD_ID")
19
- return if ENV.key?("SKIP_INTERACTIVE")
20
-
21
- Dir.mkdir(TEST_RENDERS_DIR) unless File.exist?(TEST_RENDERS_DIR)
22
- path = File.join(TEST_RENDERS_DIR, name_tag + '.png')
23
- magick_image.format = 'png'
24
- magick_image.write(path)
25
- `open #{path}`
26
- end
27
-
28
- def examine_image_from_string(string)
29
- # When doing TDD, waiting for stuff to open is a drag - allow
30
- # it to be squelched using 2 envvars. Also viewing images
31
- # makes no sense on CI unless we bother with artifacts.
32
- # The first one is what Gitlab-CI sets for us.
33
- return if ENV.key?("CI_BUILD_ID")
34
- return if ENV.key?("SKIP_INTERACTIVE")
35
-
36
- Dir.mkdir(TEST_RENDERS_DIR) unless File.exist?(TEST_RENDERS_DIR)
37
- random_name = 'test-image-%s' % SecureRandom.hex(3)
38
- path = File.join(TEST_RENDERS_DIR, random_name)
39
- File.open(path, 'wb'){|f| f << string }
40
- `open #{path}`
41
- end
42
- end
43
-
44
- require 'simplecov'
45
- SimpleCov.start do
46
- add_filter "/spec/"
47
- end
48
-
49
- require_relative '../lib/image_vise'
50
-
51
- RSpec.configure do | config |
52
- config.order = 'random'
53
- config.include Examine
54
- config.before :suite do
55
- TestServer.start(nil, ssl=false, port=9001)
56
- end
57
-
58
- config.after :each do
59
- ImageVise.reset_allowed_hosts!
60
- ImageVise.reset_secret_keys!
61
- end
62
-
63
- config.after :suite do
64
- sleep 2
65
- FileUtils.rm_rf(TEST_RENDERS_DIR)
66
- end
67
-
68
- def test_image_path
69
- File.expand_path(__dir__ + '/waterside_magic_hour.jpg')
70
- end
71
-
72
- def test_image_path_psd
73
- File.expand_path(__dir__ + '/waterside_magic_hour.psd')
74
- end
75
-
76
- def test_image_path_tif
77
- File.expand_path(__dir__ + '/waterside_magic_hour_gray.tif')
78
- end
79
-
80
- def test_image_adobergb_path
81
- File.expand_path(__dir__ + '/waterside_magic_hour_adobergb.jpg')
82
- end
83
-
84
- def public_url
85
- 'http://localhost:9001/waterside_magic_hour.jpg'
86
- end
87
-
88
- def public_url_psd
89
- 'http://localhost:9001/waterside_magic_hour.psd'
90
- end
91
-
92
- def public_url_psd_multilayer
93
- 'http://localhost:9001/layers-with-blending.psd'
94
- end
95
-
96
- def public_url_tif
97
- 'http://localhost:9001/waterside_magic_hour_gray.tif'
98
- end
99
-
100
- config.around :each do |e|
101
- STRICT_ENV.with_protected_env { e.run }
102
- end
103
- end
data/spec/test_server.rb DELETED
@@ -1,61 +0,0 @@
1
- require 'webrick'
2
- include WEBrick
3
-
4
- class ForbiddenServlet < HTTPServlet::AbstractServlet
5
- def do_GET(req,res)
6
- res['Content-Type'] = "text/plain"
7
- res.status = 403
8
- end
9
- end
10
-
11
- class TestServer
12
- def self.start( log_file = nil, ssl = false, port = 9001 )
13
- new(log_file, ssl, port).start
14
- end
15
-
16
- def initialize( log_file = nil, ssl = false, port = 9001 )
17
- log_file ||= StringIO.new
18
- log = WEBrick::Log.new(log_file)
19
-
20
- options = {
21
- :Port => port,
22
- :Logger => log,
23
- :AccessLog => [
24
- [ log, WEBrick::AccessLog::COMMON_LOG_FORMAT ],
25
- [ log, WEBrick::AccessLog::REFERER_LOG_FORMAT ]
26
- ],
27
- :DocumentRoot => File.expand_path(__dir__),
28
- }
29
-
30
- if ssl
31
- options[:SSLEnable] = true
32
- options[:SSLCertificate] = OpenSSL::X509::Certificate.new(File.open("spec/certs/cacert.pem").read)
33
- options[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(File.open("spec/certs/privkey.pem").read)
34
- options[:SSLCertName] = [ ["CN", WEBrick::Utils::getservername ] ]
35
- end
36
-
37
- @server = WEBrick::HTTPServer.new(options)
38
- @server.mount("/forbidden", ForbiddenServlet)
39
- end
40
-
41
- def start
42
- trap('INT') {
43
- begin
44
- @server.shutdown unless @server.nil?
45
- rescue Object => e
46
- $stderr.puts "Error #{__FILE__}:#{__LINE__}\n#{e.message}"
47
- end
48
- }
49
-
50
- @thread = Thread.new { @server.start }
51
- Thread.pass
52
- self
53
- end
54
-
55
- def join
56
- if defined? @thread and @thread
57
- @thread.join
58
- end
59
- self
60
- end
61
- end
Binary file
Binary file
Binary file
Binary file
Binary file