tinyimage 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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/tinyimage +30 -0
  3. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e719426e966fd7414594252d1c8716ed0611e1d4
4
+ data.tar.gz: 70dcf789a4c7b1b401ff9bc8c10411c19700f476
5
+ SHA512:
6
+ metadata.gz: f61491c53d59f1f22f91a93a047962228435b5e66bab1b232d0ee40c8108911d8f39e218ffe93ea2175facb1963b503eff127a7d77ed82dd270e8bbcdfb3490c
7
+ data.tar.gz: 661bcccc1ea6c38543919d6ed4ae6d28c247e7846ff170022424b1742d104377b649c85c3d65bba097910f52149b53ff68c1eea78c0afdbf987bc4f1f0f55463
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ require 'tinify'
3
+ require 'highline'
4
+
5
+ def command?(name)
6
+ `which #{name}`
7
+ $?.success?
8
+ end
9
+
10
+ abort("Please install 'pngpaste' via homebrew!") unless command? 'pngpaste'
11
+ abort("Please set TINIFY_API_KEY in your environment. Get yours at: https://tinypng.com/developers") unless ENV['TINIFY_API_KEY']
12
+
13
+ Tinify.key = ENV['TINIFY_API_KEY']
14
+
15
+ cli = HighLine.new
16
+
17
+ clipboard_ready = cli.ask("Hit enter to confirm you have an image ready to compress in the clipboard (or cntrl-C to abort)") { |q| q.default = true }
18
+
19
+ if clipboard_ready
20
+ image_data = `pngpaste - 2>/dev/null`
21
+
22
+ abort("No image found on the clipboard to compress") unless $?.success?
23
+
24
+ source = Tinify.from_buffer(image_data)
25
+
26
+ output_filename = cli.ask("Where would you like to save the optimized file?") { |q| q.default = "./optimized.png" }
27
+
28
+ source.to_file(output_filename)
29
+ end
30
+
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tinyimage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Johnstone
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: CLI tool for compressing an image on the clipboard
14
+ email: rubygems-tinyimage@jeremyjohnstone.com
15
+ executables:
16
+ - tinyimage
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/tinyimage
21
+ homepage: https://github.com/jsjohnst/tinyimage
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.6.13
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: TinyPNG CLI client
45
+ test_files: []