mob_image_factory 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ca7124918555dda4c401a2806e4c432c00ce51c9
4
+ data.tar.gz: 87f51a3e9929e9349f3c4d654c5770dd85e263c5
5
+ SHA512:
6
+ metadata.gz: b5f9b34866fb14f221072ccb0e1a2396bd665cac274acd2ad9bbdb71f7e6d7c526d7206a8340debe35bd2d1cd8bb896b3dbb974cf115895ac13b198e7aab3b5a
7
+ data.tar.gz: 8e50e9211e854951aeb350338c1c99d72f57deb230b8c9e5e3693311fa4dafb006bddf32c88b16c05ea7c9d5d626a06f5178a8a3b60d0f47a4d27d91f4d02e65
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'mob_image_factory'
3
+
4
+ mif = MobImageFactory.new(ARGV)
5
+ puts mif.produce
@@ -0,0 +1,55 @@
1
+ class MobImageFactory
2
+ def initialize(args)
3
+ @args = args
4
+ end
5
+
6
+ def produce
7
+ if @args.empty? || @args.size < 2
8
+ return usage
9
+ end
10
+ @type = @args[0]
11
+ @infilename = @args[1]
12
+ @outfilename = @args[2].nil? ? @infilename : @args[2]
13
+
14
+ system "identify #{@infilename}"
15
+
16
+ if @type == 'android_icon'
17
+ #Android App icons
18
+ convert 192, "android", "xxxhdpi"
19
+ convert 144, "android", "xxhdpi"
20
+ convert 96, "android", "xhdpi"
21
+ convert 72, "android", "hdpi"
22
+ convert 48, "android", "mdpi"
23
+ elsif @type == 'android_notification_icon'
24
+ #Android Notification icons
25
+ convert_greyscale 96, "android", "xxxhdpi"
26
+ convert_greyscale 72, "android", "xxhdpi"
27
+ convert_greyscale 48, "android", "xhdpi"
28
+ convert_greyscale 36, "android", "hdpi"
29
+ convert_greyscale 24, "android", "mdpi"
30
+ else
31
+ return usage
32
+ end
33
+
34
+ "Done"
35
+ end
36
+
37
+ private
38
+ def convert_greyscale(size, platform, folder, filename_prepend = "")
39
+ convert size, platform, folder, filename_prepend, "-colorspace Gray"
40
+ end
41
+
42
+ def convert(size, platform, folder, filename_prepend = "", extra_cmd_options = "")
43
+ system "mkdir #{platform}"
44
+ system "mkdir #{platform}/#{folder}"
45
+ system "convert #{@infilename} #{extra_cmd_options} -resize #{size}x#{size} #{platform}/#{folder}/#{filename_prepend}#{@outfilename}"
46
+ puts "convert #{@infilename} #{extra_cmd_options} -resize #{size}x#{size} #{platform}/#{folder}/#{filename_prepend}#{@outfilename}"
47
+ end
48
+
49
+ def usage
50
+ "\n"+
51
+ "Usage: mob_image_factory convert_type <filename> <optional_output_filename>\n\n"+
52
+ "convert_types: android_icon, android_notification_icon"+
53
+ "\n\n"
54
+ end
55
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mob_image_factory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mike Howson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Convert an image to all required sizes for iOS and Android
14
+ email: mike.howson@p4innovation.com
15
+ executables:
16
+ - mob_image_factory
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/mob_image_factory
21
+ - lib/mob_image_factory.rb
22
+ homepage: http://rubygems.org/gems/mob_image_factory.rb
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.4.6
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Mobile OS Image Convertor
46
+ test_files: []