pixelart 1.3.3 → 1.3.4
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/Manifest.txt +1 -0
- data/lib/pixelart/base.rb +4 -0
- data/lib/pixelart/convert.rb +54 -0
- data/lib/pixelart/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 07a749afe60b5174e207574ab916bfd4a41dd844897ec1375947b170cb155fb9
|
|
4
|
+
data.tar.gz: 4a5f82ec221fb71a3d4db47cb131d86a8f4c778b3eaaae22f42c55492025e4c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 10845c93bda5c7ab3186e84b4621028a435eda87dca9c5e651f5259dc482c9d3d00a3da72054a262a43baa79e18e3f82cca7960bb15b1076a7ed2c121caf1d17
|
|
7
|
+
data.tar.gz: 5c77a94549a22310c07f08e380a1029d538e7e2d5eced92b24ce65a64824e2ecfb9374f03184edfb480e1d8fa2ca6cbfc22cf8ba09d30459ca995080a0f9defd
|
data/Manifest.txt
CHANGED
data/lib/pixelart/base.rb
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Pixelart
|
|
2
|
+
|
|
3
|
+
class Image
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## helper to convert (all) image in directory
|
|
7
|
+
## chech: move to ImageUtils.convert or such - why? why not?
|
|
8
|
+
##
|
|
9
|
+
## what about the name e.g. rename to convert_dir or
|
|
10
|
+
## batch_convert such - why? why not?
|
|
11
|
+
def self.convert( dir, from: 'jpg',
|
|
12
|
+
to: 'png',
|
|
13
|
+
outdir: nil,
|
|
14
|
+
overwrite: true )
|
|
15
|
+
|
|
16
|
+
outdir = dir if outdir.nil?
|
|
17
|
+
|
|
18
|
+
files = Dir.glob( "#{dir}/*.#{from}" )
|
|
19
|
+
puts "==> found #{files.size} image(s) to convert from #{from} to #{to} (overwrite mode set to: #{overwrite})"
|
|
20
|
+
|
|
21
|
+
files.each_with_index do |file,i|
|
|
22
|
+
dirname = File.dirname( file )
|
|
23
|
+
extname = File.extname( file )
|
|
24
|
+
basename = File.basename( file, extname )
|
|
25
|
+
|
|
26
|
+
## skip convert if target / dest file already exists
|
|
27
|
+
next if overwrite == false && File.exist?( "#{outdir}/#{basename}.#{to}" )
|
|
28
|
+
|
|
29
|
+
## note: make sure outdir exists (magic will not create it??)
|
|
30
|
+
FileUtils.mkdir_p( outdir ) unless Dir.exist?( outdir )
|
|
31
|
+
|
|
32
|
+
cmd = "magick convert #{dirname}/#{basename}.#{from} #{outdir}/#{basename}.#{to}"
|
|
33
|
+
|
|
34
|
+
puts " [#{i+1}/#{files.size}] - #{cmd}"
|
|
35
|
+
## todo/fix: check return value!!! magick comand not available (in path) and so on!!!
|
|
36
|
+
system( cmd )
|
|
37
|
+
|
|
38
|
+
if from == 'gif'
|
|
39
|
+
## assume multi-images for gif
|
|
40
|
+
## save image-0.png to image.png
|
|
41
|
+
path0 = "#{outdir}/#{basename}-0.#{to}"
|
|
42
|
+
path = "#{outdir}/#{basename}.#{to}"
|
|
43
|
+
|
|
44
|
+
puts " saving #{path0} to #{path}..."
|
|
45
|
+
|
|
46
|
+
blob = File.open( path0, 'rb' ) { |f| f.read }
|
|
47
|
+
File.open( path, 'wb' ) { |f| f.write( blob ) }
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
end # class Image
|
|
54
|
+
end # class Pixelart
|
data/lib/pixelart/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pixelart
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gerald Bauer
|
|
@@ -119,6 +119,7 @@ files:
|
|
|
119
119
|
- lib/pixelart/blur.rb
|
|
120
120
|
- lib/pixelart/circle.rb
|
|
121
121
|
- lib/pixelart/composite.rb
|
|
122
|
+
- lib/pixelart/convert.rb
|
|
122
123
|
- lib/pixelart/generator.rb
|
|
123
124
|
- lib/pixelart/image.rb
|
|
124
125
|
- lib/pixelart/led.rb
|