acts-as-func 1.3.1 → 1.4.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.
- checksums.yaml +4 -4
- data/lib/tmagick.rb +37 -31
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db0ad53c3c6a33cbaf082ae3128e43cec098616e
|
4
|
+
data.tar.gz: c8aa81b95916f4878fe38ff82d528ec767866d6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77b7cf71e835fac8400e91228d179b2cde6b56b3e0953dce8ad74ea1395eac157a5a4796e00e17056e33a7e5b1e99f3b34da5aa8820436ee20711ad23694253c
|
7
|
+
data.tar.gz: a00ddde5f9d706ac0b7d7547e085ce625a533585499aced788d8b94048a93ae257e5d52c20d68ea9319cdb0f00446f2c41ba69b816e3c7576225828e8414cb86
|
data/lib/tmagick.rb
CHANGED
@@ -1,37 +1,43 @@
|
|
1
1
|
class Tmagick
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
#画图类
|
3
|
+
#img->底图 "#{Rails.root}/public/images/1.jpg"
|
4
|
+
#newimg->处理完保存的地址 save img handle path example->"#{Rails.root}/public/images/new.jpg"
|
5
|
+
#example-> Tmagick.new("1.jpg","public/n.jpg").images(images),texts(texts).images(imgs).write
|
6
|
+
def initialize(img, newimg=nil)
|
7
|
+
@pushimg = Magick::Image.read(img).first
|
8
|
+
@poppath = newimg.blank? ? img : newimg
|
9
|
+
end
|
10
|
+
|
11
|
+
#图片叠加和水印
|
12
|
+
#images->多图片叠加,数组,在一个图片上画多个图片; image=>{img: "1.jpg", x: 0, y: 0},img要画的图片地址,xy画的左顶点位置
|
13
|
+
#return->成功返回当前对象,失败返回nil
|
14
|
+
def images(images)
|
15
|
+
return nil if images.blank?
|
16
|
+
images.each do |img|
|
17
|
+
@pushimg.composite!(Magick::Image.read(img[:img]).first, img[:x], img[:y], Magick::OverCompositeOp)
|
15
18
|
end
|
19
|
+
return self
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
copyright.fill = fontobj[:color]
|
31
|
-
copyright.annotate(img, 0, 0, fontobj[:x], fontobj[:y]+12, fontobj[:text])
|
32
|
-
end
|
33
|
-
newimg = newimg.blank? ? img1 : newimg
|
34
|
-
img.write(newimg)
|
22
|
+
#图片上写字
|
23
|
+
#fontobjs 文字数组; fontobj=>{text: "aaaaaaaaa",color: "#000000",font: "simsun.ttc'",size: 20,weight: 100, x: 0, y: 0}
|
24
|
+
# text文字内容,color颜色,font字体,size大小,weight粗细,xy画的左顶点位置
|
25
|
+
#return-》成功返回当前对象,失败返回nil
|
26
|
+
def texts(texts)
|
27
|
+
return nil if texts.blank?
|
28
|
+
texts.each do |text|
|
29
|
+
copyright = Magick::Draw.new
|
30
|
+
copyright.font = text[:font]
|
31
|
+
copyright.pointsize = text[:size]
|
32
|
+
copyright.font_weight = text[:weight]
|
33
|
+
copyright.fill = text[:color]
|
34
|
+
copyright.annotate(@pushimg, 0, 0, text[:x], text[:y]+12, text[:text])
|
35
35
|
end
|
36
|
+
return self
|
37
|
+
end
|
38
|
+
|
39
|
+
#写出操作
|
40
|
+
def write
|
41
|
+
@pushimg.write(@poppath)
|
36
42
|
end
|
37
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts-as-func
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lean
|
@@ -33,17 +33,17 @@ require_paths:
|
|
33
33
|
- lib
|
34
34
|
required_ruby_version: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- -
|
36
|
+
- - '>='
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
45
|
rubyforge_project:
|
46
|
-
rubygems_version: 2.4.
|
46
|
+
rubygems_version: 2.4.8
|
47
47
|
signing_key:
|
48
48
|
specification_version: 4
|
49
49
|
summary: acts-as-func!
|