nx-watermark 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +28 -0
- data/Rakefile +2 -0
- data/__tests__/app.rb +7 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/nx/version.rb +5 -0
- data/lib/nx/watermark.rb +17 -0
- data/nx-watermark-0.1.0.gem +0 -0
- data/nx-watermark.gemspec +36 -0
- data/package.json +23 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd27f96a7df4f4caafa41bb5a8d18be7499d4e5c320bdfe8648ab20ec0bc7ff7
|
4
|
+
data.tar.gz: 0aa08bb4661ef1dd44fcf976a231cd25ac704872f5a172de59244067500bded2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d655c40cc21b964f2d9aa19ea94d68df064497324d86ac30438c33eec60254c79fa9f6c51ec4c1a6e2bd911a973165a01cbf37d8c9be4405b2f5bc65d7b0525f
|
7
|
+
data.tar.gz: 583a71c72d453e96ca2e3d0a615f9119e3c2122d548987066704448fe73739d014cb7e5829d5196c02daea879839cd290f7b591f4a4a06202e639d43e397413a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# nx-watermark
|
2
|
+
> Watermark use mini_magick.
|
3
|
+
|
4
|
+
## installation
|
5
|
+
```rb
|
6
|
+
# from gem
|
7
|
+
gem 'nx-watermark'
|
8
|
+
# from git
|
9
|
+
gem 'nx-watermark', git: 'git@github.com:afeiship/nx-watermark.git'
|
10
|
+
```
|
11
|
+
|
12
|
+
## usage
|
13
|
+
```rb
|
14
|
+
Nx::Watermark.patch(
|
15
|
+
source: "https://img9.doubanio.com/view/ark_article_cover/retina/public/12051836.jpg?v=0",
|
16
|
+
watermark: "__tests__/watermark_20.png",
|
17
|
+
dest: "__tests__/dist.png",
|
18
|
+
)
|
19
|
+
```
|
20
|
+
|
21
|
+
## build/publish
|
22
|
+
```shell
|
23
|
+
# build
|
24
|
+
gem build nx-watermark.gemspec
|
25
|
+
|
26
|
+
# publish
|
27
|
+
gem push nx-watermark-0.1.0.gem
|
28
|
+
```
|
data/Rakefile
ADDED
data/__tests__/app.rb
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "nx-watermark"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/nx/version.rb
ADDED
data/lib/nx/watermark.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Nx
|
2
|
+
class Watermark
|
3
|
+
def self.patch(in_options)
|
4
|
+
source_image = MiniMagick::Image.open(in_options[:source])
|
5
|
+
water_image = MiniMagick::Image.new(in_options[:watermark])
|
6
|
+
result = source_image.composite(water_image) do |config|
|
7
|
+
config.gravity "center"
|
8
|
+
config.compose "Over"
|
9
|
+
if block_given?
|
10
|
+
yield config
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
result.write in_options[:dest]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
Binary file
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "nx/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "nx-watermark"
|
8
|
+
spec.version = Nx::Watermark::VERSION
|
9
|
+
spec.licenses = ["MIT"]
|
10
|
+
spec.authors = ["afeiship"]
|
11
|
+
spec.email = ["1290657123@qq.com"]
|
12
|
+
|
13
|
+
spec.summary = %q{Watermark for ruby.}
|
14
|
+
spec.description = %q{Watermark use mini_magick.}
|
15
|
+
spec.homepage = "https://github.com/afeiship/nx-watermark"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
34
|
+
spec.add_development_dependency "rake", "~> 12.3", ">= 12.3.3"
|
35
|
+
spec.add_dependency "mini_magick", "~> 4.10", ">= 4.10.1"
|
36
|
+
end
|
data/package.json
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"name": "nx-watermark",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "Watermark use mini_magick.",
|
5
|
+
"directories": {
|
6
|
+
"lib": "lib"
|
7
|
+
},
|
8
|
+
"scripts": {
|
9
|
+
"clean": "rm -rf *.gem",
|
10
|
+
"build": "gem build *.gemspec",
|
11
|
+
"pubpush": "gem push *.gem"
|
12
|
+
},
|
13
|
+
"repository": {
|
14
|
+
"type": "git",
|
15
|
+
"url": "git+https://github.com/afeiship/nx-watermark.git"
|
16
|
+
},
|
17
|
+
"author": "afei",
|
18
|
+
"license": "MIT",
|
19
|
+
"bugs": {
|
20
|
+
"url": "https://github.com/afeiship/nx-watermark/issues"
|
21
|
+
},
|
22
|
+
"homepage": "https://github.com/afeiship/nx-watermark#readme"
|
23
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nx-watermark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- afeiship
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,7 +71,19 @@ executables: []
|
|
71
71
|
extensions: []
|
72
72
|
extra_rdoc_files: []
|
73
73
|
files:
|
74
|
+
- ".gitignore"
|
75
|
+
- Gemfile
|
76
|
+
- README.md
|
77
|
+
- Rakefile
|
78
|
+
- __tests__/app.rb
|
79
|
+
- bin/console
|
80
|
+
- bin/setup
|
74
81
|
- lib/nx-watermark.rb
|
82
|
+
- lib/nx/version.rb
|
83
|
+
- lib/nx/watermark.rb
|
84
|
+
- nx-watermark-0.1.0.gem
|
85
|
+
- nx-watermark.gemspec
|
86
|
+
- package.json
|
75
87
|
homepage: https://github.com/afeiship/nx-watermark
|
76
88
|
licenses:
|
77
89
|
- MIT
|