pixelart 1.3.3 → 1.3.4

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: 0724e3e1f83da6ef84325d79706a2f59d773eb31478f1e4d797ff582dad64a4a
4
- data.tar.gz: 7d75ebe3aef0abb3e3d142bf787995bbcdf797416912a387601110a3547d08fe
3
+ metadata.gz: 07a749afe60b5174e207574ab916bfd4a41dd844897ec1375947b170cb155fb9
4
+ data.tar.gz: 4a5f82ec221fb71a3d4db47cb131d86a8f4c778b3eaaae22f42c55492025e4c5
5
5
  SHA512:
6
- metadata.gz: 6afe87fa92ec1de03bad71cd5f2ba298f78287b77f514a6c74cae6747c1e1d62790d722c07fb0a5d049dcf9966d4fa0a473688e71c717de534420f4746b711f2
7
- data.tar.gz: 0b1a7cf13cdffa7410a6c0246f894d3ca5f1e3b1347fd90b9f7cbe9ed3cff4b4fc87c6704d80854b5337aa5f17e24631c28bc8188e4c6f86422e862d22949d43
6
+ metadata.gz: 10845c93bda5c7ab3186e84b4621028a435eda87dca9c5e651f5259dc482c9d3d00a3da72054a262a43baa79e18e3f82cca7960bb15b1076a7ed2c121caf1d17
7
+ data.tar.gz: 5c77a94549a22310c07f08e380a1029d538e7e2d5eced92b24ce65a64824e2ecfb9374f03184edfb480e1d8fa2ca6cbfc22cf8ba09d30459ca995080a0f9defd
data/Manifest.txt CHANGED
@@ -7,6 +7,7 @@ lib/pixelart/base.rb
7
7
  lib/pixelart/blur.rb
8
8
  lib/pixelart/circle.rb
9
9
  lib/pixelart/composite.rb
10
+ lib/pixelart/convert.rb
10
11
  lib/pixelart/generator.rb
11
12
  lib/pixelart/image.rb
12
13
  lib/pixelart/led.rb
data/lib/pixelart/base.rb CHANGED
@@ -63,6 +63,10 @@ require 'pixelart/blur'
63
63
 
64
64
 
65
65
 
66
+ ###
67
+ # mover helpers / utils
68
+ require 'pixelart/convert'
69
+
66
70
 
67
71
 
68
72
  puts Pixelart.banner # say hello
@@ -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
@@ -3,7 +3,7 @@ module Pixelart
3
3
 
4
4
  MAJOR = 1
5
5
  MINOR = 3
6
- PATCH = 3
6
+ PATCH = 4
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
9
9
  def self.version
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.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