html-pipeline-gitlab 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7665f2aba698a1f7b7c3c8194f572fb1bdc4bfc
4
- data.tar.gz: 90460359d1b82321483bd0fca1ab9088507f6532
3
+ metadata.gz: 1a04526910d21f11a1ed3fb6454963fa945d735b
4
+ data.tar.gz: aa1094422047dd9abc6f21f256db333d5bd822b2
5
5
  SHA512:
6
- metadata.gz: cdce34f98a7100bbea473e5ad46237ebb52d4eaafa71dec4d1c480f1711a94fde3ba218a7002fa418e8ac2c64f352fe3b5b0305f402b4644100a287fec995915
7
- data.tar.gz: 07b1cef40313ae90d8fba3989dc0cab60f44ac8fd419b8ab9ee83fbe020689b2bdaee465dcb87c1e7504eb27d89357a915c3e9b0fd6b63856bd0d20cc4f94072
6
+ metadata.gz: 4534b8f0a609dc402022277731c89c79eb5f6092c1ef262539872db562691c32d01cde63f9d1d90af2d2aaa5e3ad838859b047f96f794e81f68f21dfca36d89b
7
+ data.tar.gz: 7fff5f62c408bb0fe8a39961ee60800642d25c9652c274bf66148e0a941f334d105566b816ec798ffe2e37a29af67a813194bfd6cdd75a8fc865e5c8b95098e2
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_runtime_dependency 'gitlab_emoji', '~> 0.0.1'
27
27
  spec.add_runtime_dependency 'sanitize', '~> 2.1'
28
28
  spec.add_runtime_dependency 'actionpack', '~> 4'
29
- spec.add_runtime_dependency 'rmagick'
29
+ spec.add_runtime_dependency 'mime-types'
30
30
  end
@@ -1,5 +1,5 @@
1
1
  require 'base64'
2
- require 'RMagick'
2
+ require 'mime-types'
3
3
  require 'html/pipeline/filter'
4
4
  require 'uri'
5
5
 
@@ -28,19 +28,13 @@ module HTML
28
28
  end
29
29
 
30
30
  def base64_encode_image(file_path)
31
- img = Magick::Image.read(file_path).first
32
- # Strip profiles and comments from file
33
- img.strip!
34
- if img.filesize > 100_000
35
- img.format = 'JPG'
36
- # Resize it to be maximum 600px * 600px.
37
- img.resize_to_fit!(600, 600)
38
- encoded_image = Base64.encode64(img.to_blob { self.quality = 60 })
39
- else
40
- encoded_image = Base64.encode64(img.to_blob)
41
- end
31
+ mime_type = MIME::Types.type_for(file_path).first
32
+ return nil if mime_type.nil?
42
33
 
43
- "data:image/jpg;base64,#{encoded_image}"
34
+ content_type = mime_type.content_type
35
+ img = File.read(file_path)
36
+ encoded_image = Base64.encode64(img)
37
+ "data:#{content_type};base64,#{encoded_image}"
44
38
  end
45
39
 
46
40
  def get_file_path(url, upload_path, base_url)
@@ -1,7 +1,7 @@
1
1
  module Html
2
2
  module Pipeline
3
3
  module Gitlab
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline-gitlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Schilling
@@ -110,7 +110,7 @@ dependencies:
110
110
  - !ruby/object:Gem::Version
111
111
  version: '4'
112
112
  - !ruby/object:Gem::Dependency
113
- name: rmagick
113
+ name: mime-types
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - ">="