artbase 0.2.0 → 0.2.1
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/README.md +26 -28
- data/Rakefile +2 -0
- data/lib/artbase/collection/base.rb +39 -1
- data/lib/artbase/collection/token.rb +17 -7
- data/lib/artbase/helper.rb +3 -2
- data/lib/artbase/tool.rb +16 -0
- data/lib/artbase/version.rb +1 -2
- data/lib/artbase.rb +11 -36
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 549b31d6f628fcb714c22fd03f179b75fd9b99e9c2bbe8532b1e79660e4f1ade
|
4
|
+
data.tar.gz: aadb6b67430375da20a83e94362562405dfca370dac2b8cfe514086a926ff2df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7d1a745322df0250841c03975135d35f0f4ab4a9b8258e36482258e14b1847cece236b09755fd8962b6e942b21ed1ee5b28449c0d0b4d32f9f3c7c08e508533
|
7
|
+
data.tar.gz: 735c9079a101dd5aea55d5cb8458256082864e07bcaef81dff178cdeabb583df381ff9880d6aca7871c094a7f529342a9a206f4a4d877efe9c9b6b6b2600c27f
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# artbase ("right-clicker") command line tool & scripts - download complete pixel art collections - yes, you can! - automate "right-click 'n'
|
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
2
|
|
3
3
|
* home :: [github.com/pixelartexchange/artbase](https://github.com/pixelartexchange/artbase)
|
4
4
|
* bugs :: [github.com/pixelartexchange/artbase/issues](https://github.com/pixelartexchange/artbase/issues)
|
@@ -43,7 +43,7 @@ meta_slugify: /^Blocky Doge #(?<num>[0-9]+)$/,
|
|
43
43
|
```
|
44
44
|
|
45
45
|
Sorry for the "magic" config format for now -
|
46
|
-
see the [**
|
46
|
+
see the [**artbase.sandbox**](https://github.com/pixelartexchange/artbase.sandbox) for many more "real-world" examples.
|
47
47
|
|
48
48
|
|
49
49
|
|
@@ -66,11 +66,11 @@ Let's try:
|
|
66
66
|
$ artbase blockydoge meta
|
67
67
|
```
|
68
68
|
|
69
|
-
Note: All meta data files get stored by convention in `blockydoge/
|
69
|
+
Note: All token meta data files get stored by convention in `blockydoge/token`.
|
70
70
|
Resulting in a file tree like:
|
71
71
|
|
72
72
|
```
|
73
|
-
blockydoge/
|
73
|
+
blockydoge/token/
|
74
74
|
0.json
|
75
75
|
1.json
|
76
76
|
2.json
|
@@ -87,20 +87,18 @@ blockydoge/meta/
|
|
87
87
|
...
|
88
88
|
```
|
89
89
|
|
90
|
-
Example - `blockydoge/
|
90
|
+
Example - `blockydoge/token/0.json`:
|
91
91
|
|
92
92
|
``` json
|
93
93
|
{
|
94
94
|
"id": 52224520,
|
95
95
|
"token_id": "154226446513437...7290852067901441",
|
96
|
-
"num_sales": 1,
|
97
96
|
"image_url": "https://lh3.googleusercontent.com/fIQQ0A7...gTlbgMTQ",
|
98
97
|
"image_preview_url": "https://lh3.googleusercontent.com/fIQQ0A7...gTlbgMTQ=s250",
|
99
98
|
"image_thumbnail_url": "https://lh3.googleusercontent.com/fIQQ0A7...gTlbgMTQ=s128",
|
100
99
|
"image_original_url": null,
|
101
100
|
"name": "Blocky Doge #1",
|
102
101
|
"description": "Blocky Doge ... 100 unique pixelated Doge avatars...",
|
103
|
-
"external_link": null,
|
104
102
|
|
105
103
|
...
|
106
104
|
|
@@ -116,7 +114,7 @@ Example - `blockydoge/meta/0.json`:
|
|
116
114
|
|
117
115
|
|
118
116
|
|
119
|
-
### Download all referenced images in the meta data file
|
117
|
+
### Download all referenced images in the token meta data file
|
120
118
|
|
121
119
|
Let's try:
|
122
120
|
|
@@ -125,11 +123,11 @@ $ artbase blockydoge img
|
|
125
123
|
```
|
126
124
|
|
127
125
|
Note: All referenced images (in the source format e.g. 512x512)
|
128
|
-
get stored by convention in `blockydoge/i`.
|
126
|
+
get stored by convention in `blockydoge/token-i`.
|
129
127
|
Resulting in a file tree like:
|
130
128
|
|
131
129
|
```
|
132
|
-
blockydoge/i/
|
130
|
+
blockydoge/token-i/
|
133
131
|
0.png
|
134
132
|
1.png
|
135
133
|
2.png
|
@@ -146,7 +144,7 @@ blockydoge/i/
|
|
146
144
|
...
|
147
145
|
```
|
148
146
|
|
149
|
-
Example - `blockydoge/i/0.png` (512x512):
|
147
|
+
Example - `blockydoge/token-i/0.png` (512x512):
|
150
148
|
|
151
149
|

|
152
150
|
|
@@ -163,29 +161,29 @@ $ artbase blockydoge px
|
|
163
161
|
```
|
164
162
|
|
165
163
|
Note: All referenced images pixelated down to the orginal format (e.g. 60x60)
|
166
|
-
get stored by convention in `blockydoge/
|
164
|
+
get stored by convention in `blockydoge/60x60`.
|
167
165
|
Resulting in a tree like:
|
168
166
|
|
169
167
|
```
|
170
|
-
blockydoge/
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
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
|
184
182
|
...
|
185
183
|
```
|
186
184
|
|
187
185
|
|
188
|
-
Example - `blockydoge/
|
186
|
+
Example - `blockydoge/60x60/1.png` to `13.png`:
|
189
187
|
|
190
188
|

|
191
189
|

|
@@ -271,4 +269,4 @@ Use it as you please with no restrictions whatsoever.
|
|
271
269
|
|
272
270
|
## Questions? Comments?
|
273
271
|
|
274
|
-
Post them on the [
|
272
|
+
Post them on the [D.I.Y. Punk (Pixel) Art reddit](https://old.reddit.com/r/DIYPunkArt). Thanks.
|
data/Rakefile
CHANGED
@@ -3,6 +3,36 @@ module Artbase
|
|
3
3
|
class Base ## "abstract" Base collection - check -use a different name - why? why not?
|
4
4
|
|
5
5
|
|
6
|
+
def convert_images( overwrite: )
|
7
|
+
image_dir = "./#{slug}/token-i"
|
8
|
+
Image.convert( image_dir, from: 'jpg', to: 'png', overwrite: overwrite )
|
9
|
+
Image.convert( image_dir, from: 'gif', to: 'png', overwrite: overwrite )
|
10
|
+
Image.convert( image_dir, from: 'svg', to: 'png', overwrite: overwrite )
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
def make_strip
|
16
|
+
composite_count = @count - @excludes.size
|
17
|
+
|
18
|
+
composite = ImageComposite.new( 9, 1,
|
19
|
+
width: @width,
|
20
|
+
height: @height )
|
21
|
+
|
22
|
+
i = 0
|
23
|
+
each_image do |img, id|
|
24
|
+
puts "==> [#{i+1}/9] #{id}"
|
25
|
+
composite << img
|
26
|
+
|
27
|
+
i += 1
|
28
|
+
break if i >= 9
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
composite.save( "./#{@slug}/tmp/#{@slug}-strip.png" )
|
33
|
+
end
|
34
|
+
|
35
|
+
|
6
36
|
|
7
37
|
def make_composite
|
8
38
|
### use well-known / pre-defined (default) grids
|
@@ -16,14 +46,22 @@ def make_composite
|
|
16
46
|
when 314 then [15, 21]
|
17
47
|
when 500 then [25, 20]
|
18
48
|
when 1000 then [25, 40]
|
49
|
+
when 2200 then [50, 44]
|
50
|
+
when 2222 then [50, 45]
|
51
|
+
when 2469 then [50, 50]
|
19
52
|
when 3000 then [100, 30] ## or use 50*60 - why? why not?
|
20
53
|
when 3500 then [100, 35] ## or use 50*x ??
|
21
54
|
when 3979 then [100, 40]
|
22
55
|
when 4000 then [100, 40] ## or use 50x80 - why? why not?
|
56
|
+
when 4444 then [100, 45] ## or use 50x??
|
23
57
|
when 5000 then [100, 50] ## or use 50x100 - why? why not?
|
24
58
|
when 5555 then [100, 56] # 5600 (45 left empty)
|
59
|
+
when 6666 then [100, 67] # 6700 (34 left empty)
|
60
|
+
when 6688 then [100, 67] # 6700 (12 left empty)
|
25
61
|
when 6969 then [100, 70] # 7000 (31 left empty)
|
26
|
-
when
|
62
|
+
when 8888 then [100, 89]
|
63
|
+
when 9969 then [100,100]
|
64
|
+
when 10000 then [100,100]
|
27
65
|
else
|
28
66
|
raise ArgumentError, "sorry - unknown composite count #{composite_count}/#{@count} for now"
|
29
67
|
end
|
@@ -17,9 +17,13 @@ class Meta
|
|
17
17
|
|
18
18
|
|
19
19
|
def name
|
20
|
-
|
20
|
+
## note: name might be an integer number e.g. 0/1/2 etc.
|
21
|
+
## e.g. see crypto pudgy punks and others?
|
22
|
+
## always auto-convert to string
|
23
|
+
@name ||= _normalize( @data['name'].to_s )
|
21
24
|
end
|
22
25
|
|
26
|
+
|
23
27
|
def description
|
24
28
|
@description ||= _normalize( @data['description'] )
|
25
29
|
end
|
@@ -323,19 +327,25 @@ end
|
|
323
327
|
|
324
328
|
## note: default to direct true if image_base present/availabe
|
325
329
|
## otherwise to false
|
330
|
+
## todo/check: change/rename force para to overwrite - why? why not?
|
326
331
|
def download_images( range=_range, force: false,
|
327
332
|
direct: @image_base ? true : false )
|
328
333
|
start = Time.now
|
329
334
|
delay_in_s = 0.3
|
330
335
|
|
331
336
|
range.each do |id|
|
332
|
-
## note: for now assumes only .png format!!!
|
333
|
-
## todo - check for more format - why? why not?
|
334
|
-
outpath = "./#{@slug}/token-i/#{id}.png"
|
335
|
-
if !force && File.exist?( outpath )
|
336
|
-
next ## note: skip if file already exists
|
337
|
-
end
|
338
337
|
|
338
|
+
## note: skip if (downloaded) file already exists
|
339
|
+
skip = false
|
340
|
+
if !force
|
341
|
+
['png', 'gif', 'jgp', 'svg'].each do |format|
|
342
|
+
if File.exist?( "./#{@slug}/token-i/#{id}.#{format}" )
|
343
|
+
skip = true
|
344
|
+
break
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
next if skip
|
339
349
|
|
340
350
|
image_src = image_url( id: id, direct: direct )
|
341
351
|
|
data/lib/artbase/helper.rb
CHANGED
@@ -10,7 +10,8 @@ end
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
|
13
|
+
=begin
|
14
|
+
moved/ use Image.convert !!! remove here
|
14
15
|
def convert_images( collection, from: 'jpg',
|
15
16
|
to: 'png',
|
16
17
|
dir: 'i',
|
@@ -45,7 +46,7 @@ def convert_images( collection, from: 'jpg',
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
48
|
-
|
49
|
+
=end
|
49
50
|
|
50
51
|
|
51
52
|
|
data/lib/artbase/tool.rb
CHANGED
@@ -93,12 +93,16 @@ class Tool
|
|
93
93
|
download_meta( offset: options[ :offset] )
|
94
94
|
elsif ['i', 'img', 'image', 'images'].include?( command )
|
95
95
|
download_images( offset: options[ :offset] )
|
96
|
+
elsif ['conv', 'convert'].include?( command )
|
97
|
+
convert_images
|
96
98
|
elsif ['a', 'attr', 'attributes'].include?( command )
|
97
99
|
dump_attributes
|
98
100
|
elsif ['x', 'exp', 'export'].include?( command )
|
99
101
|
export_attributes
|
100
102
|
elsif ['c', 'composite'].include?( command )
|
101
103
|
make_composite
|
104
|
+
elsif ['strip'].include?( command )
|
105
|
+
make_strip
|
102
106
|
elsif ['t', 'test'].include?( command )
|
103
107
|
puts " testing, testing, testing"
|
104
108
|
else
|
@@ -113,6 +117,18 @@ class Tool
|
|
113
117
|
@collection.make_composite
|
114
118
|
end
|
115
119
|
|
120
|
+
def self.convert_images
|
121
|
+
puts "==> convert images"
|
122
|
+
@collection.convert_images( overwrite: false )
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
def self.make_strip
|
127
|
+
puts "==> make strip"
|
128
|
+
@collection.make_strip
|
129
|
+
end
|
130
|
+
|
131
|
+
|
116
132
|
def self.dump_attributes
|
117
133
|
puts "==> dump attributes"
|
118
134
|
@collection.dump_attributes
|
data/lib/artbase/version.rb
CHANGED
data/lib/artbase.rb
CHANGED
@@ -1,42 +1,16 @@
|
|
1
|
-
require '
|
2
|
-
require 'time'
|
3
|
-
require 'date'
|
1
|
+
require 'cocos'
|
4
2
|
|
5
|
-
require 'uri'
|
6
|
-
require 'net/http'
|
7
|
-
require 'net/https'
|
8
|
-
require 'cgi'
|
9
|
-
require 'fileutils'
|
10
3
|
|
11
|
-
require 'json'
|
12
4
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
##################
|
19
|
-
#### commons convenience helpers
|
20
|
-
### - move read_json( path ) to shared commons/prolog/... or such - why? why not?
|
21
|
-
|
22
|
-
def read_json( path )
|
23
|
-
txt = File.open( path, 'r:utf-8' ) { |f| f.read }
|
24
|
-
data = JSON.parse( txt )
|
25
|
-
data
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
## our own gems
|
5
|
+
## 3rd party gems
|
32
6
|
require 'pixelart'
|
33
7
|
|
34
8
|
|
35
9
|
|
36
10
|
|
37
|
-
|
38
11
|
## our own code
|
39
|
-
|
12
|
+
require_relative 'artbase/version' # note: let version always go first
|
13
|
+
|
40
14
|
|
41
15
|
### add (shared) "global" config
|
42
16
|
module Artbase
|
@@ -60,17 +34,18 @@ def self.config() @config ||= Configuration.new; end
|
|
60
34
|
end # module Artbase
|
61
35
|
|
62
36
|
|
63
|
-
|
37
|
+
require_relative 'artbase/image'
|
38
|
+
|
64
39
|
|
40
|
+
require_relative 'artbase/helper'
|
41
|
+
require_relative 'artbase/retry' ## (global) retry_on_error helper
|
65
42
|
|
66
|
-
|
67
|
-
|
43
|
+
require_relative 'artbase/collection'
|
44
|
+
require_relative 'artbase/attributes'
|
68
45
|
|
69
|
-
require 'artbase/collection'
|
70
|
-
require 'artbase/attributes'
|
71
46
|
|
47
|
+
require_relative 'artbase/tool'
|
72
48
|
|
73
|
-
require 'artbase/tool'
|
74
49
|
|
75
50
|
|
76
51
|
######
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: artbase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cocos
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.2
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: webclient
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +38,20 @@ dependencies:
|
|
24
38
|
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: 0.2.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pixelart
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.6
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.6
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: rdoc
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|