qiniu-rs 2.3.2 → 2.3.3

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qiniu-rs (2.3.2)
4
+ qiniu-rs (2.3.3)
5
5
  json (~> 1.7.3)
6
6
  mime-types (~> 1.19)
7
7
  rest-client (~> 1.6.7)
data/docs/README.md CHANGED
@@ -31,6 +31,7 @@ title: Ruby SDK 使用指南 | 七牛云存储
31
31
  - [取消公开外链](#unpublish)
32
32
  - [图像处理](#op-image)
33
33
  - [查看图片属性信息](#image_info)
34
+ - [查看图片EXIF信息](#image_exif)
34
35
  - [获取指定规格的缩略图预览地址](#image_preview_url)
35
36
  - [高级图像处理(缩略、裁剪、旋转、转化)](#image_mogrify_preview_url)
36
37
  - [高级图像处理(缩略、裁剪、旋转、转化)并持久化](#image_mogrify_save_as)
@@ -484,6 +485,24 @@ height
484
485
  colorModel
485
486
  : 原始图片着色模式
486
487
 
488
+ <a name="image_exif"></a>
489
+
490
+ #### 查看图片EXIF信息
491
+
492
+ Qiniu::RS.image_exif(url)
493
+
494
+ 使用 SDK 提供的 `Qiniu::RS.image_exif` 方法,可以基于一张存储于七牛云存储服务器上的原始图片图片,取到该图片的 EXIF 信息。
495
+
496
+ **参数**
497
+
498
+ url
499
+ : 必须,字符串类型(String),原图的下载链接,需是 `Qiniu::RS.get`(或`Qiniu::RS.batch_get`)函数返回值中 `url` 字段的值,或者是 `Qiniu::RS.download`(或`Qiniu::RS.batch_download`)函数返回的下载链接。且文件本身必须是图片。
500
+
501
+ **返回值**
502
+
503
+ 如果参数 `url` 所代表的图片没有 EXIF 信息,返回 `false`。否则,返回一个包含 EXIF 信息的 Hash 结构。
504
+
505
+
487
506
  <a name="image_preview_url"></a>
488
507
 
489
508
  #### 获取指定规格的缩略图预览地址
@@ -505,6 +524,7 @@ spec
505
524
  返回一个字符串类型的缩略图 URL
506
525
 
507
526
 
527
+
508
528
  <a name="image_mogrify_preview_url"></a>
509
529
 
510
530
  #### 高级图像处理(缩略、裁剪、旋转、转化)
@@ -533,7 +553,7 @@ mogrify_options
533
553
  :auto_orient => <TrueOrFalse>
534
554
  }
535
555
 
536
- `Qiniu::RS.image_mogrify_preview_url()` 方法是对七牛云存储图像处理高级接口的完整包装,关于 `mogrify_options` 参数里边的具体含义和使用方式,可以参考文档:[图像处理高级接口](#/v2/api/foimg/#fo-imageMogr)。
556
+ `Qiniu::RS.image_mogrify_preview_url()` 方法是对七牛云存储图像处理高级接口的完整包装,关于 `mogrify_options` 参数里边的具体含义和使用方式,可以参考文档:[图像处理高级接口](/v2/api/foimg/#fo-imageMogr)。
537
557
 
538
558
  **返回值**
539
559
 
@@ -574,7 +594,7 @@ mogrify_options
574
594
  :auto_orient => <TrueOrFalse>
575
595
  }
576
596
 
577
- `Qiniu::RS::Image.mogrify_preview_url()` 方法是对七牛云存储图像处理高级接口的完整包装,关于 `mogrify_options` 参数里边的具体含义和使用方式,可以参考文档:[图像处理高级接口](#/v2/api/foimg/#fo-imageMogr)。
597
+ `Qiniu::RS::Image.mogrify_preview_url()` 方法是对七牛云存储图像处理高级接口的完整包装,关于 `mogrify_options` 参数里边的具体含义和使用方式,可以参考文档:[图像处理高级接口](/v2/api/foimg/#fo-imageMogr)。
578
598
 
579
599
  **返回值**
580
600
 
data/lib/qiniu/rs.rb CHANGED
@@ -124,6 +124,11 @@ module Qiniu
124
124
  code == StatusOK ? data : false
125
125
  end
126
126
 
127
+ def image_exif(url)
128
+ code, data = Image.exif(url)
129
+ code == StatusOK ? data : false
130
+ end
131
+
127
132
  def image_preview_url(url, spec)
128
133
  Image.preivew_url(url, spec)
129
134
  end
@@ -10,6 +10,10 @@ module Qiniu
10
10
  Utils.http_request url + '/imageInfo', nil, {:method => :get}
11
11
  end
12
12
 
13
+ def exif(url)
14
+ Utils.http_request url + '?exif', nil, {:method => :get}
15
+ end
16
+
13
17
  def preivew_url(url, spec)
14
18
  url + '/imagePreview/' + spec.to_s
15
19
  end
@@ -29,7 +33,7 @@ module Qiniu
29
33
  params_string += %Q(/#{key}/#{opts[key]}) unless opts[key].nil?
30
34
  end
31
35
  params_string += '/auto-orient' unless opts["auto_orient"].nil?
32
- 'imageMogr' + params_string
36
+ 'imageMogr' + URI.escape(params_string)
33
37
  end
34
38
 
35
39
  end
@@ -49,10 +49,10 @@ module Qiniu
49
49
  header_options.merge!('Authorization' => auth_token) unless auth_token.nil?
50
50
  case options[:method]
51
51
  when :get
52
- response = RestClient.get url, header_options
52
+ response = RestClient.get(url, header_options)
53
53
  when :post
54
54
  header_options.merge!(:content_type => options[:content_type])
55
- response = RestClient.post url, data, header_options
55
+ response = RestClient.post(url, data, header_options)
56
56
  end
57
57
  code = response.respond_to?(:code) ? response.code.to_i : 0
58
58
  if code != 200
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Qiniu
4
4
  module RS
5
- VERSION = "2.3.2"
5
+ VERSION = "2.3.3"
6
6
  end
7
7
  end
@@ -36,7 +36,6 @@ module Qiniu
36
36
  :file => local_file,
37
37
  :bucket => @bucket,
38
38
  :key => @key,
39
- :mime_type => "image/png",
40
39
  :enable_crc32_check => true
41
40
  result.should be_true
42
41
 
@@ -47,7 +46,7 @@ module Qiniu
47
46
  @source_image_url = result["url"]
48
47
 
49
48
  @mogrify_options = {
50
- :thumbnail => "!120x120r",
49
+ :thumbnail => "!120x120>",
51
50
  :gravity => "center",
52
51
  :crop => "!120x120a0a0",
53
52
  :quality => 85,
@@ -65,6 +64,13 @@ module Qiniu
65
64
  end
66
65
  end
67
66
 
67
+ context ".exif" do
68
+ it "should works" do
69
+ code, data = Qiniu::RS::Image.exif(@source_image_url)
70
+ puts data.inspect
71
+ end
72
+ end
73
+
68
74
  context ".mogrify_preview_url" do
69
75
  it "should works" do
70
76
  mogrify_preview_url = Qiniu::RS::Image.mogrify_preview_url(@source_image_url, @mogrify_options)
@@ -164,6 +164,17 @@ module Qiniu
164
164
  end
165
165
  end
166
166
 
167
+ context ".image_exif" do
168
+ it "should works" do
169
+ data = Qiniu::RS.get(@test_image_bucket, @test_image_key)
170
+ data.should_not be_false
171
+ data.should_not be_empty
172
+ puts data.inspect
173
+ result = Qiniu::RS.image_exif(data["url"])
174
+ puts result.inspect
175
+ end
176
+ end
177
+
167
178
  context ".image_mogrify_save_as" do
168
179
  it "should works" do
169
180
  data = Qiniu::RS.get(@test_image_bucket, @test_image_key)
@@ -175,7 +186,7 @@ module Qiniu
175
186
  dest_key = "cropped-" + @test_image_key
176
187
  src_img_url = data["url"]
177
188
  mogrify_options = {
178
- :thumbnail => "!120x120r",
189
+ :thumbnail => "!120x120>",
179
190
  :gravity => "center",
180
191
  :crop => "!120x120a0a0",
181
192
  :quality => 85,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qiniu-rs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -177,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  segments:
179
179
  - 0
180
- hash: -274925002457974401
180
+ hash: -269804960925193007
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  version: '0'
187
187
  segments:
188
188
  - 0
189
- hash: -274925002457974401
189
+ hash: -269804960925193007
190
190
  requirements: []
191
191
  rubyforge_project:
192
192
  rubygems_version: 1.8.24