carrierwave-picture 0.2.2 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d477a008bf8e84fd52a69dc333be1fabf90399c297b4e0d518296f5172ff522e
4
- data.tar.gz: b6542efd6888b6e0ed3894b5a3a5c90de6b8855253e30499846e14fa5eeab7c1
3
+ metadata.gz: 1de00efe56dca1e604d1f956f38bf2de3a551dfdbb45d93f178d422db69dd693
4
+ data.tar.gz: a347cf52d04c1b983adbd520defe89e5fde646299d488e08f8ed0453e7301ad5
5
5
  SHA512:
6
- metadata.gz: 8e015dcfb2108b012aaef86f24d531489a67a8b54322ff1806f7900c17d5ed64e4dab2d5c76cf7755a434f91900d6b19a9bcefce16ccac80cc04a19a6d68f65b
7
- data.tar.gz: 0b08e900f213064b5cf91a03ccc6297a4add78e43819d343f23eedbbece7a71a3b74b0b985ba083ef924526a877fa8dabf1943465f9d93a7b923e70be413aa8d
6
+ metadata.gz: e19ad6a3ddba35da9e868305d4546983373fda6d1edc4b933e6dd0d7f7983560de10442e4457e497dbb66841c5daa37acbec8bc659cd28b51bb36905b0d3c013
7
+ data.tar.gz: 4fdc8105aaaab2928b3fd281fc744b1afc6de3bafb823f119e6ac8b00462bb1596cef03a8924e1ca1b5572b7ae317b4bcb727d14487ef83c62895a4d2147b75c
data/README.md CHANGED
@@ -60,6 +60,14 @@ It is return html code like:
60
60
  </picture>
61
61
  ```
62
62
 
63
+ If you have uploaded images you can use rake task to convert. Default path is "public":
64
+
65
+ $ rake picture:prepare[:path]
66
+
67
+ Example:
68
+
69
+ $ rake picture:prepare["public/uploads"]
70
+
63
71
  ## Contributing
64
72
 
65
73
  1. Fork it
@@ -1,6 +1,12 @@
1
1
  module PictureConverter
2
2
  def self.convert(current_path)
3
- system "convert -interlace Plane -quality 80 #{current_path} #{current_path}.webp" unless File.extname(current_path) == "webp"
4
- system "convert -interlace Plane -quality 80 #{current_path} #{current_path}.jp2" unless File.extname(current_path) == "jp2"
3
+
4
+ unless File.exist?("#{current_path}.webp")
5
+ system "convert -interlace Plane -quality 80 #{current_path} #{current_path}.webp"
6
+ end
7
+ unless File.exist?("#{current_path}.jp2")
8
+ system "convert -interlace Plane -quality 80 #{current_path} #{current_path}.jp2"
9
+ end
10
+
5
11
  end
6
12
  end
@@ -1,5 +1,5 @@
1
1
  module PictureHelper
2
- def self.picture_tag(path, options = {})
2
+ def picture_tag(path, options = {})
3
3
 
4
4
  content_tag(:picture, options) do
5
5
  concat content_tag :source,
@@ -6,6 +6,10 @@ module Picture
6
6
  initializer 'picture.helper' do |app|
7
7
  ActionView::Base.send :include, PictureHelper
8
8
  end
9
+
10
+ rake_tasks do
11
+ load 'tasks/picture.rake'
12
+ end
9
13
  end
10
14
 
11
15
  end
@@ -1,5 +1,5 @@
1
1
  module Carrierwave
2
2
  module Picture
3
- VERSION = "0.2.2"
3
+ VERSION = "0.3.3"
4
4
  end
5
5
  end
@@ -0,0 +1,24 @@
1
+ namespace :picture do
2
+ desc "Picture task converting uploaded images to webp and jp2 formats"
3
+
4
+ task :prepare, [:path] do |task, args|
5
+ p "This may take some time..."
6
+
7
+ path = args[:path] || 'public'
8
+
9
+ ["png", "jpg", "jpeg", "gif"].each do |dim|
10
+
11
+ Dir[ path + "/**/*.{#{dim}}" ].each do |file|
12
+ p "#{file} converting"
13
+
14
+ begin
15
+ PictureConverter.convert(file)
16
+ rescue => e
17
+ p e
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-picture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Pavlov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-02 00:00:00.000000000 Z
11
+ date: 2018-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave
@@ -95,6 +95,7 @@ files:
95
95
  - lib/carrierwave-picture/picture_helper.rb
96
96
  - lib/carrierwave-picture/railtie.rb
97
97
  - lib/carrierwave-picture/version.rb
98
+ - lib/tasks/picture.rake
98
99
  homepage: https://github.com/PavlovIgor/carrierwave-picture
99
100
  licenses:
100
101
  - MIT