ordinals 0.0.1 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24a92228c4c130bdb9083c1fa9dea7d458d827d99533935191fe5f31c4c750c8
4
- data.tar.gz: 1807eb1c8472696cff5c46ef41b8e7126517e56a7f458e352e5aa39aaa537d65
3
+ metadata.gz: 8713aa7b98dcb5356b762898b13ab4539313ef8621f2930b5291519edd759f50
4
+ data.tar.gz: 6c4a9f720237c5e6468eede3f7b69988ecbdcf5fd347749cd9f18dd9de0fdb6a
5
5
  SHA512:
6
- metadata.gz: 1b40c581901fe69993d189bcd520a9c6d47cb90a7d1e5512764cc79842e21f3651b8862f3b2de62ca131ca721eaf73745721a775e80b7ec0b064e10da530bc7e
7
- data.tar.gz: '036823aabca7d9c3d5deb3dfa404a7d4bfe22caecec84ff21f61fac10f44ae3f18217bbc0f80cb269aad35e6e61c74b375de3615bebe0b02e97482f0ccecabaa'
6
+ metadata.gz: 803d2f9357b35101f2572767de7f7176966d077b2b87bef45b2cb6c1f90c80ec4513d71aad231e08ddc5a112683ac0c24139a40e832f714dac05b47039654b3f
7
+ data.tar.gz: 64071daa9c9c4352174a4be0c5cce8a7ee5d407920c922f29cadf8d015ab5ce963cc922f665039bfa3397142383aeeef3cff4e8c4650ec96faec32a33f6bddf3
data/Manifest.txt CHANGED
@@ -2,4 +2,6 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ bin/ordbase
5
6
  lib/ordinals.rb
7
+ lib/ordinals/collection.rb
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ordinals
2
2
 
3
- ordinals gem - (off-chain) ordinals (pixel art) machinery & helpers for Bitcoin & co.
3
+ ordinals gem - "right-clicker" (off-chain) ordinals (pixel art) machinery & helpers for Bitcoin & co.
4
4
 
5
5
 
6
6
  * home :: [github.com/pixelartexchange/ordinals.sandbox](https://github.com/pixelartexchange/ordinals.sandbox)
@@ -9,9 +9,151 @@ ordinals gem - (off-chain) ordinals (pixel art) machinery & helpers for Bitcoin
9
9
  * rdoc :: [rubydoc.info/gems/ordinals](http://rubydoc.info/gems/ordinals)
10
10
 
11
11
 
12
- ## Usage
12
+ ## Comand-Line Usage
13
13
 
14
- To be done
14
+ Let's use the 100 Ordinal Punks collection to try out the
15
+ `ordbase` command-line tool shipping with the ordinals package.
16
+
17
+ Tip: New to Ordinal Punks? For some background see [**Awesome 100 Ordinal Punks (Anno 2023) Notes - 24×24 Pixel Art on the (Bitcoin) Blockchain »**](https://github.com/cryptopunksnotdead/cryptopunks/tree/master/awesome-ordinalpunks)
18
+
19
+
20
+ ### Step 0: Prepare A Tabular Dataset (List) Of All Ordinals w/ ID
21
+
22
+ For now a manual step - prepare a list of all ordinals with id in the comma-separated values (.csv) tabular dataset format.
23
+ Example - [ordinalpunks/ordinals.csv](https://github.com/pixelartexchange/ordinals.sandbox/blob/master/ordinalpunks/ordinals.csv):
24
+
25
+ ``` csv
26
+ num, id
27
+ 1, 96d87d7e59d75ebc0e6144b09fdd96355fcdaa86fd098d64c46f19a424012bbei0
28
+ 2, acda637db995df796b35035fd978cc1a947f1e6fd5215968da88b7e38a7e4b37i0
29
+ 3, 0406654dffdd01a49794bd8531bf33721986cc7c6546f871962adee921a39a9di0
30
+ 4, 2fe9bb034f60db694701acb23a76c3d7d5aba4328dbd315764f6ee406ba41786i0
31
+ 5, dcfa240f2681d1e4a8948120a3a64567262e3c78d5497cb4e97351bfa836b638i0
32
+ 6, 16df62c86321895df2b93236d103c935015ed77e189485be649ce2c7e6ac8a4ei0
33
+ 7, 81e8d9159b8e9a27c692a5bb3ba18ca037757e94e975b53e175eaaeb2c52f15ai0
34
+ 8, c2e15fe87c4b1fd61de65f2804858e6d1152b6316bcb9c2b39b69c9c21638f5di0
35
+ 9, 3ed569f3a92ade9f1b47031eb2db2045e7dee3e00787954a88c67ed2ad9854bbi0
36
+ ...
37
+ ```
38
+
39
+
40
+ ### Step 1: Download All Pixel Art Images Via Ordinals.com
41
+
42
+ Use
43
+
44
+ ```
45
+ $ ordbase ordinalpunks image # or
46
+ $ ordbase ordinalpunks img
47
+ ```
48
+
49
+ to download all images via the ordinals.com (web) service.
50
+ All images get stored in the (temporary) `token-i/` directory.
51
+ Resulting in:
52
+
53
+ ```
54
+ /ordinalpunks
55
+ ordinals.csv
56
+ /token-i
57
+ 1.png
58
+ 2.png
59
+ 3.png
60
+ ...
61
+ ```
62
+
63
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinals/i/1.png)
64
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinals/i/2.png)
65
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinals/i/3.png)
66
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinals/i/4.png)
67
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinals/i/5.png)
68
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinals/i/6.png)
69
+ ...
70
+
71
+
72
+
73
+
74
+ ### Step 2: Downsample ("Pixelate") All Pixel Art Images
75
+
76
+ Note: Most pixel art collections upload / inscribe images with a zoom.
77
+ The ordinal punks, for example, use a 8x zoom factor for the 24×24px originals, thus,
78
+ resulting in 192×192px.
79
+
80
+
81
+ Add a ["artbase-compatible"](https://github.com/pixelartexchange/artbase) collection configuration file to lists the source format(s)
82
+ and the minimal true pixel format.
83
+ Example - [ordinalpunks/collection.yml](https://github.com/pixelartexchange/ordinals.sandbox/blob/master/ordinalpunks/collection.yml):
84
+
85
+ ``` yaml
86
+ slug: ordinalpunks
87
+ count: 100
88
+ format: 24x24
89
+ source: 192x192
90
+ offset: 1
91
+ ```
92
+
93
+ Use
94
+
95
+ ```
96
+ $ ordbase ordinalpunks pixelate # or
97
+ $ ordbase ordinalpunks px
98
+ ```
99
+
100
+ to downsample ("pixelate") all images
101
+ in the (temporary) `token-i/` directory.
102
+ Resulting in a `24x24`/ directory with all images
103
+ in the "minimal" `24x24` format:
104
+
105
+ ```
106
+ /ordinalpunks
107
+ ordinals.csv
108
+ collections.yml
109
+ /24x24
110
+ 1.png
111
+ 2.png
112
+ 3.png
113
+ ...
114
+ ```
115
+
116
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinalpunks/24x24/1.png)
117
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinalpunks/24x24/2.png)
118
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinalpunks/24x24/3.png)
119
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinalpunks/24x24/4.png)
120
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinalpunks/24x24/5.png)
121
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/ordinalpunks/24x24/6.png)
122
+ ...
123
+
124
+
125
+
126
+ ### Bonus: Step 3: Make An All-In-One Collect'Em All Composite Image
127
+
128
+
129
+ Use
130
+
131
+ ```
132
+ $ ordbase ordinalpunks composite # or
133
+ $ ordbase ordinalpunks comp
134
+ ```
135
+
136
+ to make an all-in-one image composite for the complete collection.
137
+ Resulting in `/tmp/ordinalpunks.png` (~11kb).
138
+
139
+
140
+ ![](https://github.com/pixelartexchange/ordinals.sandbox/raw/master/i/ordinalpunks.png)
141
+
142
+
143
+ That's it for now.
144
+
145
+
146
+
147
+
148
+ ## Bonus: More Ordinal Pixel Art Collections
149
+
150
+
151
+ See the [**Ordinals (Pixel Art) Sandbox (& Cache)**](https://github.com/pixelartexchange/ordinals.sandbox)
152
+ for more collections incl. Bitcoin Punks (24×24), Ordinal Mini Doges (24×24),
153
+ Extra Ordinal Women (32×32), Ordinal Penguins (35×35),
154
+ Ordinal Birds (42×42), Bitcoin Bears (48×48) and much more.
155
+
156
+ Add your sandbox or "right-clicker" ordinal backup / archive / gallery here. Yes, you can.
15
157
 
16
158
 
17
159
 
data/Rakefile CHANGED
@@ -10,9 +10,9 @@ end
10
10
 
11
11
  Hoe.spec 'ordinals' do
12
12
 
13
- self.version = '0.0.1'
13
+ self.version = '0.1.0'
14
14
 
15
- self.summary = "ordinals gem - (off-chain) ordinals (pixel art) machinery & helpers for Bitcoin & co."
15
+ self.summary = 'ordinals gem - "right-clicker" (off-chain) ordinals (pixel art) machinery & helpers for Bitcoin & co.'
16
16
  self.description = summary
17
17
 
18
18
  self.urls = { home: 'https://github.com/pixelartexchange/ordinals.sandbox' }
data/bin/ordbase ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # == DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/ordbase
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/ordbase
13
+ #
14
+
15
+ require 'ordinals'
16
+
17
+ Ordinals::Tool.main
@@ -0,0 +1,194 @@
1
+
2
+ module Ordinals
3
+
4
+
5
+ class Collection
6
+ attr_reader :slug,
7
+ :width, :height,
8
+ :sources
9
+
10
+
11
+ def initialize( slug )
12
+ @slug = slug
13
+
14
+ ## read config if present
15
+ config_path = "./#{@slug}/collection.yml"
16
+ if File.exist?( config_path )
17
+ config = read_yaml( config_path )
18
+ pp config
19
+
20
+ @width, @height = _parse_dimension( config['format'] )
21
+
22
+ ## note: allow multiple source formats / dimensions
23
+ ### e.g. convert 512x512 into [ [512,512] ]
24
+ ##
25
+ source = config['source']
26
+ source = [source] unless source.is_a?( Array )
27
+ @sources = source.map { |dimension| _parse_dimension( dimension ) }
28
+ end
29
+ end
30
+
31
+
32
+ def ordinals
33
+ @ordinals ||= begin
34
+ recs = read_csv( "./#{@slug}/ordinals.csv" )
35
+ puts " #{recs.size} record(s)"
36
+ recs
37
+ end
38
+ @ordinals
39
+ end
40
+
41
+ def count() ordinals.size; end
42
+ alias_method :size, :count
43
+
44
+
45
+
46
+ def each_ordinal( &block )
47
+ ordinals.each do |rec| ## pass along hash rec for now - why? why not?
48
+ block.call( rec )
49
+ end
50
+ end
51
+
52
+ ## add each_source_image or each_token_image or each_original_image or such - why? why not??
53
+
54
+
55
+
56
+ def each_image( &block )
57
+ each_ordinal do |rec|
58
+ id = rec['id']
59
+ num = rec['num'].to_i(10)
60
+
61
+ path = "./#{@slug}/#{@width}x#{@height}/#{num}.png"
62
+ img = Image.read( path )
63
+
64
+ block.call( img, num )
65
+ end
66
+ end
67
+
68
+
69
+
70
+ def image_dir() "./#{@slug}/token-i"; end
71
+
72
+
73
+
74
+ ## e.g. convert dimension (width x height) "24x24" or "24 x 24" to [24,24]
75
+ def _parse_dimension( str )
76
+ str.split( /x/i ).map { |str| str.strip.to_i }
77
+ end
78
+
79
+
80
+ def pixelate
81
+ each_ordinal do |rec|
82
+ id = rec['id']
83
+ num = rec['num']
84
+
85
+ outpath = "./#{@slug}/#{@width}x#{@height}/#{num}.png"
86
+ next if File.exist?( outpath )
87
+
88
+ path = "#{image_dir}/#{num}.png"
89
+ puts "==> reading #{path}..."
90
+
91
+ img = Image.read( path )
92
+ puts " #{img.width}x#{img.height}"
93
+
94
+ ## check for source images
95
+ if !@sources.include?( [img.width, img.height] )
96
+ puts " !! ERROR - unexpected image size; sorry - expected:"
97
+ pp @sources
98
+ exit 1
99
+ end
100
+
101
+ ## check for special case source == format!!
102
+ if [img.width,img.height] == [@width,@height]
103
+ puts " note: saving image as is - no downsampling"
104
+ img.save( outpath )
105
+ else
106
+ steps_x = Image.calc_sample_steps( img.width, @width )
107
+ steps_y = Image.calc_sample_steps( img.height, @height )
108
+
109
+ img = img.sample( steps_x, steps_y )
110
+ img.save( outpath )
111
+ end
112
+ end
113
+ end
114
+
115
+
116
+ def make_composite
117
+ cols, rows = case count
118
+ when 10 then [5, 2]
119
+ when 15 then [5, 3]
120
+ when 69 then [10, 7]
121
+ when 99 then [10, 10]
122
+ when 100 then [10, 10]
123
+ when 111 then [11, 11]
124
+ else
125
+ raise ArgumentError, "sorry - unknown composite count #{count} for now"
126
+ end
127
+
128
+ composite = ImageComposite.new( cols, rows,
129
+ width: @width,
130
+ height: @height )
131
+
132
+
133
+ each_image do |img, num|
134
+ puts "==> #{num}"
135
+ composite << img
136
+ end
137
+
138
+ composite.save( "./#{@slug}/tmp/#{@slug}.png" )
139
+ end
140
+
141
+
142
+
143
+ def convert_images
144
+ ## todo: check for gifs too - why? why not?
145
+ Image.convert( image_dir, from: 'jpg',
146
+ to: 'png' )
147
+ end
148
+
149
+
150
+ def download_images
151
+ each_ordinal do |rec|
152
+ id = rec['id']
153
+ num = rec['num']
154
+
155
+ next if File.exist?( "#{image_dir}/#{num}.png" )
156
+
157
+ puts "==> downloading image ##{num}..."
158
+
159
+ image_url = "https://ordinals.com/content/#{id}"
160
+
161
+ res = Webclient.get( image_url )
162
+
163
+ if res.status.ok?
164
+ content_type = res.content_type
165
+ content_length = res.content_length
166
+
167
+ puts " content_type: #{content_type}, content_length: #{content_length}"
168
+
169
+ format = if content_type =~ %r{image/jpeg}i
170
+ 'jpg'
171
+ elsif content_type =~ %r{image/png}i
172
+ 'png'
173
+ elsif content_type =~ %r{image/gif}i
174
+ 'gif'
175
+ else
176
+ puts "!! ERROR:"
177
+ puts " unknown image format content type: >#{content_type}<"
178
+ exit 1
179
+ end
180
+
181
+ ## save image - using b(inary) mode
182
+ write_blob( "#{image_dir}/#{num}.#{format}", res.blob )
183
+
184
+ sleep( 1.0 ) ## sleep (delay_in_s)
185
+ else
186
+ puts "!! ERROR - failed to download image; sorry - #{res.status.code} #{res.status.message}"
187
+ exit 1
188
+ end
189
+ end
190
+ end
191
+
192
+ end # class Collection
193
+ end # module Ordinals
194
+
data/lib/ordinals.rb CHANGED
@@ -1,3 +1,95 @@
1
1
 
2
- puts "hello ordinals"
2
+ require 'cocos'
3
+ require 'pixelart'
3
4
 
5
+ require 'optparse'
6
+
7
+
8
+
9
+ ## our own code
10
+ require_relative 'ordinals/collection'
11
+
12
+
13
+
14
+ module Ordinals
15
+ class Tool
16
+
17
+ def self.main( args=ARGV )
18
+ puts "==> welcome to ordinals/ordbase tool with args:"
19
+ pp args
20
+
21
+ options = {
22
+ }
23
+
24
+ parser = OptionParser.new do |opts|
25
+
26
+ opts.on("-h", "--help", "Prints this help") do
27
+ puts opts
28
+ exit
29
+ end
30
+ end
31
+
32
+ parser.parse!( args )
33
+ puts "options:"
34
+ pp options
35
+
36
+ puts "args:"
37
+ pp args
38
+
39
+ if args.size < 1
40
+ puts "!! ERROR - no collection found - use <collection> <command>..."
41
+ puts ""
42
+ exit
43
+ end
44
+
45
+ slug = args[0]
46
+ command = args[1] || 'image'
47
+
48
+ if ['i','img', 'image'].include?( command )
49
+ do_download_images( slug )
50
+ elsif ['conv','convert'].include?( command )
51
+ do_convert_images( slug )
52
+ elsif ['px','pixelate' ].include?( command )
53
+ do_pixelate( slug )
54
+ elsif ['comp','composite' ].include?( command )
55
+ do_make_composite( slug )
56
+ else
57
+ puts "!! ERROR - unknown command >#{command}<, sorry"
58
+ end
59
+
60
+ puts "bye"
61
+ end
62
+
63
+
64
+
65
+ def self.do_download_images( slug )
66
+ puts "==> download images for collection >#{slug}<..."
67
+
68
+ col = Collection.new( slug )
69
+ col.download_images
70
+ end
71
+
72
+
73
+ def self.do_convert_images( slug )
74
+ puts "==> convert images for collection >#{slug}<..."
75
+
76
+ col = Collection.new( slug )
77
+ col.convert_images
78
+ end
79
+
80
+ def self.do_pixelate( slug )
81
+ puts "==> downsample / pixelate images for collection >#{slug}<..."
82
+
83
+ col = Collection.new( slug )
84
+ col.pixelate
85
+ end
86
+
87
+ def self.do_make_composite( slug )
88
+ puts "==> make composite for collection >#{slug}<..."
89
+
90
+ col = Collection.new( slug )
91
+ col.make_composite
92
+ end
93
+
94
+ end # class Tool
95
+ end # module Ordinals
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ordinals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-11 00:00:00.000000000 Z
11
+ date: 2023-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos
@@ -72,10 +72,11 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '3.23'
75
- description: ordinals gem - (off-chain) ordinals (pixel art) machinery & helpers for
76
- Bitcoin & co.
75
+ description: ordinals gem - "right-clicker" (off-chain) ordinals (pixel art) machinery
76
+ & helpers for Bitcoin & co.
77
77
  email: wwwmake@googlegroups.com
78
- executables: []
78
+ executables:
79
+ - ordbase
79
80
  extensions: []
80
81
  extra_rdoc_files:
81
82
  - CHANGELOG.md
@@ -86,7 +87,9 @@ files:
86
87
  - Manifest.txt
87
88
  - README.md
88
89
  - Rakefile
90
+ - bin/ordbase
89
91
  - lib/ordinals.rb
92
+ - lib/ordinals/collection.rb
90
93
  homepage: https://github.com/pixelartexchange/ordinals.sandbox
91
94
  licenses:
92
95
  - Public Domain
@@ -111,6 +114,6 @@ requirements: []
111
114
  rubygems_version: 3.3.7
112
115
  signing_key:
113
116
  specification_version: 4
114
- summary: ordinals gem - (off-chain) ordinals (pixel art) machinery & helpers for Bitcoin
115
- & co.
117
+ summary: ordinals gem - "right-clicker" (off-chain) ordinals (pixel art) machinery
118
+ & helpers for Bitcoin & co.
116
119
  test_files: []