barf 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/lib/barf/version.rb +1 -1
- data/lib/barf.rb +8 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55081eb4528651032a7ed560be6886ae3492373054f0d8482ffa7044671a3ddc
|
4
|
+
data.tar.gz: ded67bbf6670bd22c9bd653d1fd890741c8fb2cb146fc4d79c30a8137af01e09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02a3900ab92c40b8fc68e9fcceee6a4afb74dcb25f97084fb349e09b1de7e59e002d90220627bababba86725124b251d505895be27ee7a91351bd6b79efa2ad1
|
7
|
+
data.tar.gz: 0a1431cb7fddfea311733ef8f4717513aecf49fdadc31a4ec2c9311a7f371c60ea9ea16c9b66a2dbbae76011d4f5291420b65444ec26a98a3e203fe1e11dea2c
|
data/.gitignore
CHANGED
data/lib/barf/version.rb
CHANGED
data/lib/barf.rb
CHANGED
@@ -5,15 +5,21 @@ require "tco"
|
|
5
5
|
|
6
6
|
module Barf
|
7
7
|
|
8
|
+
@palette = "inline:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAP4AAAABCAIAAABxMITKAAABpklEQVR4AW2StWIUXRTHf2d2o9+Huzv85yGooKJKic7wKukueYvZICXW0kZ67CwV7lbh7CVzd+IZ/dv1Y8Dw8PDo8uvYzHSnsIJ4oyrPQafk1KtXfWtoaKjVarXb7cHBwTm6aWJiM2wHwQZjVySUCEtPL1SliDU2QoFoHlPFARihdENWqWcZRc+qWwWy0iOiGqusW8YTlFR4iaLC5ObNbP8cXWkIjyJz9UQW6m8zbrh1SZAyyFnAYayqsRfCGpdq/Rt27mo/8YsiujhO3JjlQ1FG6wwPQVXpg+gcDrpXaQidxMl095KPoNNJVyeI6JarR5vW0eyhIh6VVu0CNykiEkaC0JGiOScEosmst9e72R0uLTbJ8RPg1DjLA2mWJvjeLp49sESjmEx7YQlf9kXcCfV3o+urKLtO3Zdo8qmrDa9t1+5LvrhNh8bH+0fcP+5N7965Un+ufuTQz58LgbnvztlZRTxHsJARFvQ44TRHl4zuCU6A3JNe465rAV8JDV7eT8qvpYfcFdMql+s7ZmYWqvTY37/NQF0p4mLdq1eZZcMjw5s2bfoHC6PO/+pdxgEAAAAASUVORK5CYII="
|
9
|
+
|
8
10
|
def self.print(path)
|
9
11
|
image = MiniMagick::Image.open(path)
|
10
12
|
|
11
13
|
terminal_width = `tput cols`.to_i
|
12
14
|
|
13
15
|
# Height must be divisible by 2 for the half pixels to be clean.
|
14
|
-
new_height = (image.height * (0.5 * terminal_width / image.width)).to_i * 2
|
16
|
+
new_height = [2, (image.height * (0.5 * terminal_width / image.width)).to_i * 2].max
|
15
17
|
|
16
|
-
image.
|
18
|
+
image.combine_options do |tmp|
|
19
|
+
tmp.resize "#{terminal_width}x#{new_height}!"
|
20
|
+
tmp.dither 'FloydSteinberg'
|
21
|
+
tmp.remap @palette
|
22
|
+
end
|
17
23
|
|
18
24
|
# Two dimensional array of pixels:
|
19
25
|
image.get_pixels.each_slice(2) do |top, bottom|
|