artbase 0.1.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa2c17e20eba3ef7a381f5643f4f2fde0d7bed07bf1ea613fe4da8a324f5c500
4
- data.tar.gz: 7f124deeb894095131e7e472286deebc0703fd2ffbfa9bb1167e58a59745c4c5
3
+ metadata.gz: 28781910e6461bf7c03b8c27a1845633c07681798180edd50f873ec029b9921f
4
+ data.tar.gz: c19bf7185dfbfe51c0f7ab14b25f4dbecd29314b0ca6088660ab55b4a4c5d40c
5
5
  SHA512:
6
- metadata.gz: 74533360be3826d67c3b3b286fdeaabbe5623df8efa4dba377a3b2d6cadf8299c858202274ac4be69be581b722ee2c81e6edd5d3193b1dd80dbe5d98264e01f1
7
- data.tar.gz: b80f2676cf847d875ac321a9ee6ffb30357fe306c88173d08bc9cddbe0928e2c722a66fe5b8b9786dede41f3b12647ff99db5b4da2138ac937d7f332f6ebe53c
6
+ metadata.gz: 17b24d4328ba8fac495134954a686b59324e7f635d878c2b1ce1c085ad9b21a3a767f87773d7dfccdb7516c47a9cf57621bec10e11daab16ae8610c2670f7ed3
7
+ data.tar.gz: e009b91051805e13358b6cb172e32ce256f04d03d0eda912dc7f6b73c35a58c6d556c4e9cb301ac8f4f88aa8d9d6e43bf6b376e2509ae856689d7224584f6bee
data/CHANGELOG.md CHANGED
@@ -1,3 +1,3 @@
1
- ### 0.0.1 / 2018-10-18
2
-
3
- * Everything is new. First release
1
+ ### 0.0.1 / 2018-10-18
2
+
3
+ * Everything is new. First release
data/Manifest.txt CHANGED
@@ -1,5 +1,4 @@
1
1
  CHANGELOG.md
2
- LICENSE.md
3
2
  Manifest.txt
4
3
  README.md
5
4
  Rakefile
@@ -7,15 +6,13 @@ bin/artbase
7
6
  lib/artbase.rb
8
7
  lib/artbase/attributes.rb
9
8
  lib/artbase/collection.rb
9
+ lib/artbase/collection/base.rb
10
10
  lib/artbase/collection/image.rb
11
11
  lib/artbase/collection/opensea.rb
12
12
  lib/artbase/collection/token.rb
13
13
  lib/artbase/helper.rb
14
14
  lib/artbase/image.rb
15
- lib/artbase/image/24x24.rb
16
- lib/artbase/image/32x32.rb
17
- lib/artbase/image/60x60.rb
18
- lib/artbase/image/80x80.rb
19
- lib/artbase/opensea.rb
15
+ lib/artbase/image/sample.rb
16
+ lib/artbase/retry.rb
20
17
  lib/artbase/tool.rb
21
18
  lib/artbase/version.rb
data/README.md CHANGED
@@ -1,39 +1,272 @@
1
- # artbase ("right-clicker") command line tool & scripts - download complete pixel art collections - yes, you can! - automate "right-click 'n' download" and much more
2
-
3
- * home :: [github.com/pixelartexchange/artbase](https://github.com/pixelartexchange/artbase)
4
- * bugs :: [github.com/pixelartexchange/artbase/issues](https://github.com/pixelartexchange/artbase/issues)
5
- * gem :: [rubygems.org/gems/artbase](https://rubygems.org/gems/artbase)
6
- * rdoc :: [rubydoc.info/gems/artbase](http://rubydoc.info/gems/artbase)
7
-
8
-
9
-
10
- ## Usage
11
-
12
-
13
- Note: The artbase is alpha - it's still the early days - it's a work-in-progress.
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
- ## Install
25
-
26
- Just install the gem:
27
-
28
- $ gem install artbase
29
-
30
-
31
- ## License
32
-
33
- The `artbase` scripts are dedicated to the public domain.
34
- Use it as you please with no restrictions whatsoever.
35
-
36
-
37
- ## Questions? Comments?
38
-
39
- Post them on the [CryptoPunksDev reddit](https://old.reddit.com/r/CryptoPunksDev). Thanks.
1
+ # artbase ("right-clicker") command line tool & scripts - download complete pixel art collections - yes, you can! - automate "right-click 'n' save" and much more
2
+
3
+ * home :: [github.com/pixelartexchange/artbase](https://github.com/pixelartexchange/artbase)
4
+ * bugs :: [github.com/pixelartexchange/artbase/issues](https://github.com/pixelartexchange/artbase/issues)
5
+ * gem :: [rubygems.org/gems/artbase](https://rubygems.org/gems/artbase)
6
+ * rdoc :: [rubydoc.info/gems/artbase](http://rubydoc.info/gems/artbase)
7
+
8
+
9
+
10
+ ## Usage
11
+
12
+
13
+ Note: The artbase is alpha - it's still the early days - it's a work-in-progress.
14
+
15
+
16
+
17
+
18
+ Let's try the 100 Blocky Doge (60x60) collection.
19
+
20
+
21
+ ### Step 0 - Collection Configuration Script
22
+
23
+ Create a directory with the collection slug (e.g. `blockydoge`)
24
+ matching the OpenSea collection slug
25
+ and add a config script - `blockydoge/config.rb`:
26
+
27
+ ``` ruby
28
+ COLLECTION = Collection.new(
29
+
30
+ 'blockydoge', # opensea collection slug
31
+ 100, # number of items
32
+
33
+ format: '60x60', # original pixel format
34
+ source: '512x512', # "big" source pixel format for
35
+ # downloaded image referenced in meta data
36
+
37
+ #####
38
+ # "automagically" get the id from the meta data name field
39
+ # via a "one-off / custom / hand-written" regex
40
+ # e.g. Blocky Doge #1 => 1
41
+ meta_slugify: /^Blocky Doge #(?<num>[0-9]+)$/,
42
+ )
43
+ ```
44
+
45
+ Sorry for the "magic" config format for now -
46
+ see the [**artbase.sandbox**](https://github.com/pixelartexchange/artbase.sandbox) for many more "real-world" examples.
47
+
48
+
49
+
50
+
51
+
52
+ That's it now you can:
53
+
54
+ - Download all meta data files via the OpenSea API
55
+ - Download all referenced images in the meta data file
56
+ - Pixelate all downloaded images from the source format (e.g. 512x512) to the original format (e.g. 60x60)
57
+ - Generate an all-in-one composite with the pixelated images
58
+ - Export all meta data attributes / traits to an all-in-one datafile in the comma-separated-values (.csv) format
59
+
60
+
61
+ ### Download all meta data files via the OpenSea API
62
+
63
+ Let's try:
64
+
65
+ ```
66
+ $ artbase blockydoge meta
67
+ ```
68
+
69
+ Note: All token meta data files get stored by convention in `blockydoge/token`.
70
+ Resulting in a file tree like:
71
+
72
+ ```
73
+ blockydoge/token/
74
+ 0.json
75
+ 1.json
76
+ 2.json
77
+ 3.json
78
+ 4.json
79
+ 5.json
80
+ 6.json
81
+ 7.json
82
+ 8.json
83
+ 9.json
84
+ 10.json
85
+ 11.json
86
+ 12.json
87
+ ...
88
+ ```
89
+
90
+ Example - `blockydoge/token/0.json`:
91
+
92
+ ``` json
93
+ {
94
+ "id": 52224520,
95
+ "token_id": "154226446513437...7290852067901441",
96
+ "image_url": "https://lh3.googleusercontent.com/fIQQ0A7...gTlbgMTQ",
97
+ "image_preview_url": "https://lh3.googleusercontent.com/fIQQ0A7...gTlbgMTQ=s250",
98
+ "image_thumbnail_url": "https://lh3.googleusercontent.com/fIQQ0A7...gTlbgMTQ=s128",
99
+ "image_original_url": null,
100
+ "name": "Blocky Doge #1",
101
+ "description": "Blocky Doge ... 100 unique pixelated Doge avatars...",
102
+
103
+ ...
104
+
105
+ "traits": [
106
+ { "trait_type": "Fur", "value": "Red Fur", ... },
107
+ { "trait_type": "Hat", "value": "Pink Party Hat", ... },
108
+ { "trait_type": "Expression", "value": "Smiley", ... },
109
+ ],
110
+
111
+ ...
112
+ }
113
+ ```
114
+
115
+
116
+
117
+ ### Download all referenced images in the token meta data file
118
+
119
+ Let's try:
120
+
121
+ ```
122
+ $ artbase blockydoge img
123
+ ```
124
+
125
+ Note: All referenced images (in the source format e.g. 512x512)
126
+ get stored by convention in `blockydoge/token-i`.
127
+ Resulting in a file tree like:
128
+
129
+ ```
130
+ blockydoge/token-i/
131
+ 0.png
132
+ 1.png
133
+ 2.png
134
+ 3.png
135
+ 4.png
136
+ 5.png
137
+ 6.png
138
+ 7.png
139
+ 8.png
140
+ 9.png
141
+ 10.png
142
+ 11.png
143
+ 12.png
144
+ ...
145
+ ```
146
+
147
+ Example - `blockydoge/token-i/0.png` (512x512):
148
+
149
+ ![](i/blockydoge0-512x512.png)
150
+
151
+
152
+
153
+
154
+
155
+ ### Pixelate all downloaded images from the source format (e.g. 512x512) to the original format (e.g. 60x60)
156
+
157
+ Let's try:
158
+
159
+ ```
160
+ $ artbase blockydoge px
161
+ ```
162
+
163
+ Note: All referenced images pixelated down to the orginal format (e.g. 60x60)
164
+ get stored by convention in `blockydoge/60x60`.
165
+ Resulting in a tree like:
166
+
167
+ ```
168
+ blockydoge/60x60/
169
+ 1.png
170
+ 2.png
171
+ 3.png
172
+ 4.png
173
+ 5.png
174
+ 6.png
175
+ 7.png
176
+ 8.png
177
+ 9.png
178
+ 10.png
179
+ 11.png
180
+ 12.png
181
+ 13.png
182
+ ...
183
+ ```
184
+
185
+
186
+ Example - `blockydoge/60x60/1.png` to `13.png`:
187
+
188
+ ![](i/blockydoge000001.png)
189
+ ![](i/blockydoge000002.png)
190
+ ![](i/blockydoge000003.png)
191
+ ![](i/blockydoge000004.png)
192
+ ![](i/blockydoge000005.png)
193
+ ![](i/blockydoge000006.png)
194
+ ![](i/blockydoge000007.png)
195
+ ![](i/blockydoge000008.png)
196
+ ![](i/blockydoge000009.png)
197
+ ![](i/blockydoge000010.png)
198
+ ![](i/blockydoge000011.png)
199
+ ![](i/blockydoge000012.png)
200
+ ![](i/blockydoge000013.png)
201
+
202
+
203
+
204
+
205
+ ### Generate an all-in-one composite with the pixelated images
206
+
207
+ Let's try:
208
+
209
+ ```
210
+ $ artbase blockydoge composite
211
+ ```
212
+
213
+ Note: The all-in-one composite image gets saved by convention to `blockydoge/tmp/blockydoge-60x60.png`. Example:
214
+
215
+ ![](i/blockydoge-60x60.png)
216
+
217
+
218
+
219
+ ### Export all meta data attributes / traits to an all-in-one datafile in the comma-separated-values (.csv) format
220
+
221
+
222
+ Let's try:
223
+
224
+ ```
225
+ $ artbase blockydoge export
226
+ ```
227
+
228
+ Note: The all-in-one datafile gets saved by convention to `blockydoge/tmp/blockydoge.csv`.
229
+ Example:
230
+
231
+
232
+ ```
233
+ ID, Name, Fur, Hat, Expression, Glasses, Accessories, Mask, Collar
234
+ 0, Blocky Doge #1, Red Fur, Pink Party Hat, Smiley, , , ,
235
+ 1, Blocky Doge #2, Black and Tan Fur, Orange Cap, Tongue Out, , , ,
236
+ 2, Blocky Doge #3, , , Cream Fur, Teal Glasses, , ,
237
+ 3, Blocky Doge #4, Meme Fur, , , Maroon Glasses, , ,
238
+ 4, Blocky Doge #5, Black and Tan Fur, Blue Party Hat, , , , ,
239
+ 5, Blocky Doge #6, Red Fur, Pink Cap, , , , ,
240
+ 6, Blocky Doge #7, Red Fur, , , , None, ,
241
+ 7, Blocky Doge #8, Meme Fur, White Cap, , , , ,
242
+ 8, Blocky Doge #9, Cream Fur, , , Sunglasses, , ,
243
+ 9, Blocky Doge #10, Meme Fur, , , , , Lavender Mask,
244
+ 10, Blocky Doge #11, Black and Tan Fur, , , Black Glasses, , ,
245
+ 11, Blocky Doge #12, Black and Tan Fur, , , , , Salmon Mask,
246
+ 12, Blocky Doge #13, Cream Fur, Green Party Hat, , , , ,
247
+ ...
248
+ ```
249
+
250
+
251
+
252
+
253
+ That's it for now.
254
+
255
+
256
+
257
+ ## Install
258
+
259
+ Just install the gem:
260
+
261
+ $ gem install artbase
262
+
263
+
264
+ ## License
265
+
266
+ The `artbase` scripts are dedicated to the public domain.
267
+ Use it as you please with no restrictions whatsoever.
268
+
269
+
270
+ ## Questions? Comments?
271
+
272
+ Post them on the [D.I.Y. Punk (Pixel) Art reddit](https://old.reddit.com/r/DIYPunkArt). Thanks.
data/Rakefile CHANGED
@@ -1,29 +1,40 @@
1
- require 'hoe'
2
- require './lib/artbase/version.rb'
3
-
4
- Hoe.spec 'artbase' do
5
-
6
- self.version = Artbase::VERSION
7
-
8
- self.summary = "artbase"
9
- self.description = summary
10
-
11
- self.urls = { home: 'https://github.com/pixelartexchange/artbase'}
12
-
13
- self.author = 'Gerald Bauer'
14
- self.email = 'wwwmake@googlegroups.com'
15
-
16
- # switch extension to .markdown for gihub formatting
17
- self.readme_file = 'README.md'
18
- self.history_file = 'CHANGELOG.md'
19
-
20
- self.extra_deps = [
21
- ]
22
-
23
- self.licenses = ['Public Domain']
24
-
25
- self.spec_extras = {
26
- required_ruby_version: '>= 2.2.2'
27
- }
28
-
29
- end
1
+ require 'hoe'
2
+ require './lib/artbase/version.rb'
3
+
4
+
5
+ ###
6
+ # hack/ quick fix for broken intuit_values - overwrite with dummy
7
+ class Hoe
8
+ def intuit_values( input ); end
9
+ end
10
+
11
+
12
+ Hoe.spec 'artbase' do
13
+
14
+ self.version = Artbase::VERSION
15
+
16
+ self.summary = "artbase"
17
+ self.description = summary
18
+
19
+ self.urls = { home: 'https://github.com/pixelartexchange/artbase'}
20
+
21
+ self.author = 'Gerald Bauer'
22
+ self.email = 'wwwmake@googlegroups.com'
23
+
24
+ # switch extension to .markdown for gihub formatting
25
+ self.readme_file = 'README.md'
26
+ self.history_file = 'CHANGELOG.md'
27
+
28
+ self.extra_deps = [
29
+ ['cocos', '>= 0.1.2'],
30
+ ['webclient', '>= 0.2.2'],
31
+ ['pixelart', '>= 1.3.6'],
32
+ ]
33
+
34
+ self.licenses = ['Public Domain']
35
+
36
+ self.spec_extras = {
37
+ required_ruby_version: '>= 2.2.2'
38
+ }
39
+
40
+ end
data/bin/artbase CHANGED
@@ -1,17 +1,17 @@
1
- #!/usr/bin/env ruby
2
-
3
- ###################
4
- # == DEV TIPS:
5
- #
6
- # For local testing run like:
7
- #
8
- # ruby -Ilib bin/artbase
9
- #
10
- # Set the executable bit in Linux. Example:
11
- #
12
- # % chmod a+x bin/artbase
13
- #
14
-
15
- require 'artbase'
16
-
17
- Artbase::Tool.main
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # == DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/artbase
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/artbase
13
+ #
14
+
15
+ require 'artbase'
16
+
17
+ Artbase::Tool.main
@@ -1,83 +1,83 @@
1
-
2
-
3
- def counter_to_text( counter )
4
-
5
- counter = counter.to_a
6
-
7
- attribute_counter = counter[0]
8
- more_counter = counter[1..-1]
9
-
10
-
11
- puts "Attribute Counts\n"
12
- trait_type, h = attribute_counter
13
-
14
- total = h[:by_type].values.reduce(0) { |sum,count| sum+count }
15
-
16
-
17
- types = h[:by_type]
18
- types = types.sort { |l,r| l[0]<=>r[0] } ## sort by name
19
-
20
- puts "\n"
21
- puts "|Name|Total (%)|"
22
- puts "|--------|----------:|"
23
-
24
- types.each do |rec|
25
- name = rec[0]
26
- count = rec[1]
27
- percent = Float(count*100)/Float(total)
28
-
29
- puts "| **#{name} Attributes** | #{count} (#{'%.2f' % percent}) |"
30
- end
31
- puts "\n"
32
-
33
- more_counter.each_with_index do |(trait_type, h),i|
34
- print " · " if i > 0 ## add separator
35
- print "#{trait_type } (#{h[:by_type].size})"
36
- end
37
- puts "\n\n"
38
-
39
-
40
-
41
- more_counter.each do |trait_type, h|
42
- print "### #{trait_type } (#{h[:by_type].size}) - "
43
- print "∑Total #{h[:count]}/#{total}\n"
44
-
45
- puts "\n"
46
- puts "|Name|Total (%)|"
47
- puts "|--------|----------:|"
48
-
49
- types = h[:by_type]
50
- types = types.sort do |l,r|
51
- # sort by 1) by count
52
- # 2) by name a-z
53
- res = r[1] <=> l[1]
54
- res = l[0] <=> r[0] if res == 0
55
- res
56
- end ## sort by count
57
- types.each do |rec|
58
- name = rec[0]
59
- count = rec[1]
60
- percent = Float(count*100)/Float(total)
61
-
62
- puts "| **#{name}** | #{count} (#{'%.2f' % percent}) |"
63
- end
64
- puts "\n\n"
65
- end
66
- end
67
-
68
-
69
-
70
-
71
- def counter_to_csv( counter )
72
-
73
- puts "type, name, count"
74
- counter.each do |trait_type, h|
75
- puts "#{trait_type}, ∑ Total, #{h[:count]}"
76
- h[:by_type].each do |trait_value, count|
77
- puts "#{trait_type}, #{trait_value}, #{count}"
78
- end
79
- end
80
- end
81
-
82
-
83
-
1
+
2
+
3
+ def counter_to_text( counter )
4
+
5
+ counter = counter.to_a
6
+
7
+ attribute_counter = counter[0]
8
+ more_counter = counter[1..-1]
9
+
10
+
11
+ puts "Attribute Counts\n"
12
+ trait_type, h = attribute_counter
13
+
14
+ total = h[:by_type].values.reduce(0) { |sum,count| sum+count }
15
+
16
+
17
+ types = h[:by_type]
18
+ types = types.sort { |l,r| l[0]<=>r[0] } ## sort by name
19
+
20
+ puts "\n"
21
+ puts "|Name|Total (%)|"
22
+ puts "|--------|----------:|"
23
+
24
+ types.each do |rec|
25
+ name = rec[0]
26
+ count = rec[1]
27
+ percent = Float(count*100)/Float(total)
28
+
29
+ puts "| **#{name} Attributes** | #{count} (#{'%.2f' % percent}) |"
30
+ end
31
+ puts "\n"
32
+
33
+ more_counter.each_with_index do |(trait_type, h),i|
34
+ print " · " if i > 0 ## add separator
35
+ print "#{trait_type } (#{h[:by_type].size})"
36
+ end
37
+ puts "\n\n"
38
+
39
+
40
+
41
+ more_counter.each do |trait_type, h|
42
+ print "### #{trait_type } (#{h[:by_type].size}) - "
43
+ print "∑Total #{h[:count]}/#{total}\n"
44
+
45
+ puts "\n"
46
+ puts "|Name|Total (%)|"
47
+ puts "|--------|----------:|"
48
+
49
+ types = h[:by_type]
50
+ types = types.sort do |l,r|
51
+ # sort by 1) by count
52
+ # 2) by name a-z
53
+ res = r[1] <=> l[1]
54
+ res = l[0] <=> r[0] if res == 0
55
+ res
56
+ end ## sort by count
57
+ types.each do |rec|
58
+ name = rec[0]
59
+ count = rec[1]
60
+ percent = Float(count*100)/Float(total)
61
+
62
+ puts "| **#{name}** | #{count} (#{'%.2f' % percent}) |"
63
+ end
64
+ puts "\n\n"
65
+ end
66
+ end
67
+
68
+
69
+
70
+
71
+ def counter_to_csv( counter )
72
+
73
+ puts "type, name, count"
74
+ counter.each do |trait_type, h|
75
+ puts "#{trait_type}, ∑ Total, #{h[:count]}"
76
+ h[:by_type].each do |trait_value, count|
77
+ puts "#{trait_type}, #{trait_value}, #{count}"
78
+ end
79
+ end
80
+ end
81
+
82
+
83
+