dzt 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/CONTRIBUTING.md +115 -7
- data/bin/dzt +6 -7
- data/lib/dzt/file_storage.rb +2 -2
- data/lib/dzt/s3_storage.rb +24 -12
- data/lib/dzt/tiler.rb +17 -15
- data/lib/dzt/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce8a839471a23570ac4124ed734deeb67747ea4d
|
4
|
+
data.tar.gz: 9f7a6fcbb80de844dfb0f4398dfb32ce7f93b214
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aa34f46fde849ee1719c4d27e4d87bb6a5fe6237cb093db7a689560ca7782b45006ccb7bdc0db1b66f0b3f4ca8b8db590ae171a012e0b36bfdf6b98ee776cc0
|
7
|
+
data.tar.gz: 8f4ac4a4d1ad796d92a52bd462bd508f19f91bce011312ff93ffc0bf504e64ece03575a4b45b46e1c0d2732565e293ff1232d8f3e7d720a83c0ae107a143eb75
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### Next Release (TBD)
|
2
|
+
|
3
|
+
* Your contribution here.
|
4
|
+
|
5
|
+
### 0.2.2 (6/12/2015)
|
6
|
+
|
7
|
+
* [#9](https://github.com/dblock/dzt/issues/9): Do not require fog unless producing output to S3, clarify require fog - [@dblock](https://github.com/dblock).
|
8
|
+
|
1
9
|
### 0.2.1 (1/2/2015)
|
2
10
|
|
3
11
|
* [#8](https://github.com/dblock/dzt/pull/8): Fixes setting quality via command line - [@dzucconi](https://github.com/dzucconi).
|
data/CONTRIBUTING.md
CHANGED
@@ -1,10 +1,118 @@
|
|
1
|
-
Contributing
|
2
|
-
|
1
|
+
Contributing to Dzt
|
2
|
+
===================
|
3
3
|
|
4
|
-
You're encouraged to
|
4
|
+
Dzt is work of [many of contributors](https://github.com/dblock/dzt/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/dblock/dzt/pulls), [propose features and discuss issues](https://github.com/dblock/dzt/issues).
|
5
5
|
|
6
|
-
|
7
|
-
* Make changes, write tests.
|
8
|
-
* Updated [CHANGELOG](CHANGELOG.md).
|
9
|
-
* Make a pull request, bonus points for topic branches.
|
6
|
+
#### Fork the Project
|
10
7
|
|
8
|
+
Fork the [project on Github](https://github.com/dblock/dzt) and check out your copy.
|
9
|
+
|
10
|
+
```
|
11
|
+
git clone https://github.com/contributor/dzt.git
|
12
|
+
cd dzt
|
13
|
+
git remote add upstream https://github.com/dblock/dzt.git
|
14
|
+
```
|
15
|
+
|
16
|
+
#### Create a Topic Branch
|
17
|
+
|
18
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
19
|
+
|
20
|
+
```
|
21
|
+
git checkout master
|
22
|
+
git pull upstream master
|
23
|
+
git checkout -b my-feature-branch
|
24
|
+
```
|
25
|
+
|
26
|
+
#### Bundle Install and Test
|
27
|
+
|
28
|
+
Ensure that you can build the project and run tests.
|
29
|
+
|
30
|
+
```
|
31
|
+
bundle install
|
32
|
+
bundle exec rake
|
33
|
+
```
|
34
|
+
|
35
|
+
#### Write Tests
|
36
|
+
|
37
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/dzt](spec/dzt).
|
38
|
+
|
39
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
40
|
+
|
41
|
+
#### Write Code
|
42
|
+
|
43
|
+
Implement your feature or bug fix.
|
44
|
+
|
45
|
+
Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
|
46
|
+
|
47
|
+
Make sure that `bundle exec rake` completes without errors.
|
48
|
+
|
49
|
+
#### Write Documentation
|
50
|
+
|
51
|
+
Document any external behavior in the [README](README.md).
|
52
|
+
|
53
|
+
#### Update Changelog
|
54
|
+
|
55
|
+
Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
|
56
|
+
|
57
|
+
#### Commit Changes
|
58
|
+
|
59
|
+
Make sure git knows your name and email address:
|
60
|
+
|
61
|
+
```
|
62
|
+
git config --global user.name "Your Name"
|
63
|
+
git config --global user.email "contributor@example.com"
|
64
|
+
```
|
65
|
+
|
66
|
+
Writing good commit logs is important. A commit log should describe what changed and why.
|
67
|
+
|
68
|
+
```
|
69
|
+
git add ...
|
70
|
+
git commit
|
71
|
+
```
|
72
|
+
|
73
|
+
#### Push
|
74
|
+
|
75
|
+
```
|
76
|
+
git push origin my-feature-branch
|
77
|
+
```
|
78
|
+
|
79
|
+
#### Make a Pull Request
|
80
|
+
|
81
|
+
Go to https://github.com/contributor/dzt and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
82
|
+
|
83
|
+
#### Rebase
|
84
|
+
|
85
|
+
If you've been working on a change for a while, rebase with upstream/master.
|
86
|
+
|
87
|
+
```
|
88
|
+
git fetch upstream
|
89
|
+
git rebase upstream/master
|
90
|
+
git push origin my-feature-branch -f
|
91
|
+
```
|
92
|
+
|
93
|
+
#### Update CHANGELOG Again
|
94
|
+
|
95
|
+
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
|
96
|
+
|
97
|
+
```
|
98
|
+
* [#123](https://github.com/dblock/dzt/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
|
99
|
+
```
|
100
|
+
|
101
|
+
Amend your previous commit and force push the changes.
|
102
|
+
|
103
|
+
```
|
104
|
+
git commit --amend
|
105
|
+
git push origin my-feature-branch -f
|
106
|
+
```
|
107
|
+
|
108
|
+
#### Check on Your Pull Request
|
109
|
+
|
110
|
+
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
111
|
+
|
112
|
+
#### Be Patient
|
113
|
+
|
114
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
|
115
|
+
|
116
|
+
#### Thank You
|
117
|
+
|
118
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
data/bin/dzt
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'gli'
|
3
3
|
require 'dzt'
|
4
|
-
require 'fog'
|
5
4
|
|
6
5
|
include GLI::App
|
7
6
|
|
@@ -9,7 +8,7 @@ program_desc 'Tile images into deep-zoom tiles'
|
|
9
8
|
|
10
9
|
default_command :slice
|
11
10
|
|
12
|
-
desc
|
11
|
+
desc 'Slice an image'
|
13
12
|
command :slice do |c|
|
14
13
|
c.flag [:o, :output, 'output'], desc: 'Output folder'
|
15
14
|
c.flag [:ts, :tilesize, 'tile-size'], desc: 'Tile size', default_value: DZT::Tiler::DEFAULT_TILE_SIZE, type: Integer
|
@@ -22,15 +21,13 @@ command :slice do |c|
|
|
22
21
|
c.flag [:s3_key, 's3-key'], desc: 'S3 Key', default_value: DZT::S3Storage::DEFAULT_KEY
|
23
22
|
c.flag [:aws_id, 'aws-id'], desc: 'AWS Id'
|
24
23
|
c.flag [:aws_secret, 'aws-secret'], desc: 'AWS Secret'
|
25
|
-
c.action do |
|
26
|
-
if args.length < 1
|
27
|
-
raise 'You must specify an image file to slice.'
|
28
|
-
end
|
24
|
+
c.action do |_global_options, options, args|
|
25
|
+
fail 'You must specify an image file to slice.' if args.length < 1
|
29
26
|
if options[:output]
|
30
27
|
storage = DZT::FileStorage.new(
|
31
28
|
destination: options[:output]
|
32
29
|
)
|
33
|
-
|
30
|
+
elsif options[:aws_id] && options[:aws_secret] && options[:bucket]
|
34
31
|
storage = DZT::S3Storage.new(
|
35
32
|
s3_acl: options[:acl],
|
36
33
|
s3_bucket: options[:bucket],
|
@@ -38,6 +35,8 @@ command :slice do |c|
|
|
38
35
|
aws_id: options[:aws_id],
|
39
36
|
aws_secret: options[:aws_secret]
|
40
37
|
)
|
38
|
+
else
|
39
|
+
fail 'You must specify either --output or --aws_id, --aws_secret and --bucket.'
|
41
40
|
end
|
42
41
|
tiler = DZT::Tiler.new(
|
43
42
|
source: args[0],
|
data/lib/dzt/file_storage.rb
CHANGED
@@ -8,7 +8,7 @@ module DZT
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def exists?
|
11
|
-
File.directory?(@store_path) && !
|
11
|
+
File.directory?(@store_path) && !Dir['@{@store_path}/*'].empty?
|
12
12
|
end
|
13
13
|
|
14
14
|
def storage_location(level)
|
@@ -24,4 +24,4 @@ module DZT
|
|
24
24
|
file.write(dest) { self.quality = quality if quality }
|
25
25
|
end
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
data/lib/dzt/s3_storage.rb
CHANGED
@@ -18,11 +18,14 @@ module DZT
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def s3
|
21
|
-
@s3 ||=
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
@s3 ||= begin
|
22
|
+
require_fog!
|
23
|
+
Fog::Storage.new(
|
24
|
+
provider: 'AWS',
|
25
|
+
aws_access_key_id: @s3_id,
|
26
|
+
aws_secret_access_key: @s3_secret
|
27
|
+
)
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
# Currently does not supporting checking S3 fo overwritten files
|
@@ -31,19 +34,28 @@ module DZT
|
|
31
34
|
end
|
32
35
|
|
33
36
|
def storage_location(level)
|
34
|
-
"#{@s3_key}/#{level
|
37
|
+
"#{@s3_key}/#{level}"
|
35
38
|
end
|
36
39
|
|
37
40
|
# no-op
|
38
|
-
def mkdir(
|
41
|
+
def mkdir(_path)
|
39
42
|
end
|
40
43
|
|
41
44
|
def write(file, dest, options = {})
|
42
45
|
quality = options[:quality]
|
43
46
|
s3.put_object(@s3_bucket, dest, file.to_blob { @quality = quality if quality },
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
'Content-Type' => file.mime_type,
|
48
|
+
'x-amz-acl' => @s3_acl
|
49
|
+
)
|
47
50
|
end
|
48
|
-
|
49
|
-
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def require_fog!
|
55
|
+
require 'fog'
|
56
|
+
rescue LoadError => e
|
57
|
+
STDERR.puts 'Fog is required for storing data in S3, run `gem install fog`.'
|
58
|
+
raise e
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/dzt/tiler.rb
CHANGED
@@ -7,7 +7,7 @@ module DZT
|
|
7
7
|
DEFAULT_TILE_SIZE = 512
|
8
8
|
DEFAULT_TILE_OVERLAP = 0
|
9
9
|
DEFAULT_QUALITY = 75
|
10
|
-
DEFAULT_TILE_FORMAT =
|
10
|
+
DEFAULT_TILE_FORMAT = 'jpg'
|
11
11
|
DEFAULT_OVERWRITE_FLAG = false
|
12
12
|
|
13
13
|
# Generates the DZI-formatted tiles and sets necessary metadata on this object.
|
@@ -22,7 +22,7 @@ module DZT
|
|
22
22
|
#
|
23
23
|
def initialize(options)
|
24
24
|
@tile_source = options[:source]
|
25
|
-
|
25
|
+
fail 'Missing options[:source].' unless @tile_source
|
26
26
|
|
27
27
|
@tile_source = Magick::Image.read(@tile_source)[0] if @tile_source.is_a?(String)
|
28
28
|
@tile_size = options[:size] || DEFAULT_TILE_SIZE
|
@@ -41,27 +41,29 @@ module DZT
|
|
41
41
|
# Generates the DZI-formatted tiles and sets necessary metadata on this object.
|
42
42
|
# Uses a default tile size of 512 pixels, with a default overlap of 2 pixel.
|
43
43
|
##
|
44
|
-
def slice!(&
|
45
|
-
|
44
|
+
def slice!(&_block)
|
45
|
+
fail "Output #{@destination} already exists!" if ! @overwrite && @storage.exists?
|
46
46
|
|
47
47
|
image = @tile_source.dup
|
48
|
-
orig_width
|
48
|
+
orig_width = image.columns
|
49
|
+
orig_height = image.rows
|
49
50
|
|
50
51
|
# iterate over all levels (= zoom stages)
|
51
52
|
max_level(orig_width, orig_height).downto(0) do |level|
|
52
|
-
width
|
53
|
+
width = image.columns
|
54
|
+
height = image.rows
|
53
55
|
|
54
56
|
current_level_storage_dir = @storage.storage_location(level)
|
55
57
|
@storage.mkdir(current_level_storage_dir)
|
56
|
-
if block_given?
|
57
|
-
yield current_level_storage_dir
|
58
|
-
end
|
58
|
+
yield current_level_storage_dir if block_given?
|
59
59
|
|
60
60
|
# iterate over columns
|
61
|
-
x
|
61
|
+
x = 0
|
62
|
+
col_count = 0
|
62
63
|
while x < width
|
63
64
|
# iterate over rows
|
64
|
-
y
|
65
|
+
y = 0
|
66
|
+
row_count = 0
|
65
67
|
while y < height
|
66
68
|
dest_path = File.join(current_level_storage_dir, "#{col_count}_#{row_count}.#{@tile_format}")
|
67
69
|
tile_width, tile_height = tile_dimensions(x, y, @tile_size, @tile_overlap)
|
@@ -94,13 +96,13 @@ module DZT
|
|
94
96
|
tile_width = (x > 0) ? overlapping_tile_size : border_tile_size
|
95
97
|
tile_height = (y > 0) ? overlapping_tile_size : border_tile_size
|
96
98
|
|
97
|
-
|
99
|
+
[tile_width, tile_height]
|
98
100
|
end
|
99
101
|
|
100
102
|
# Calculates how often an image with given dimension can
|
101
103
|
# be divided by two until 1x1 px are reached.
|
102
104
|
def max_level(width, height)
|
103
|
-
|
105
|
+
(Math.log([width, height].max) / Math.log(2)).ceil
|
104
106
|
end
|
105
107
|
|
106
108
|
# Crops part of src image and writes it to dest path.
|
@@ -114,10 +116,10 @@ module DZT
|
|
114
116
|
if src.is_a? Magick::Image
|
115
117
|
img = src
|
116
118
|
else
|
117
|
-
img = Magick::Image
|
119
|
+
img = Magick::Image.read(src).first
|
118
120
|
end
|
119
121
|
|
120
|
-
quality
|
122
|
+
quality *= 100 if quality < 1
|
121
123
|
|
122
124
|
# The crop method retains the offset information in the cropped image.
|
123
125
|
# To reset the offset data, adding true as the last argument to crop.
|
data/lib/dzt/version.rb
CHANGED
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dzt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rmagick
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description:
|
@@ -66,17 +66,17 @@ require_paths:
|
|
66
66
|
- lib
|
67
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- -
|
69
|
+
- - '>='
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '0'
|
72
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: 1.3.6
|
77
77
|
requirements: []
|
78
78
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.
|
79
|
+
rubygems_version: 2.4.5
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: Tile images for deep-zoom.
|