Commit f0ef4d18 authored by Martin Fischbach's avatar Martin Fischbach
Browse files

added resize only command for gitLab

parent 9050e028
#!/usr/bin/env ruby
require 'watchAndResize'
puts WatchAndResize.resizeOnly(ARGV[0])
\ No newline at end of file
Gem::Specification.new do |spec|
spec.name = "jekyll-img-srcset"
spec.version = "0.3.0"
spec.version = "0.3.1"
spec.authors = ["Jan-Philipp Stauffert"]
spec.email = ["jan-philipp.stauffert@uni-wuerzburg.de"]
......@@ -22,5 +22,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.16"
spec.add_development_dependency "rake", "~> 12.0"
spec.executables << 'war'
spec.executables << 'resizeOnly'
end
......@@ -3,6 +3,33 @@ require 'mini_magick'
require 'parallel'
class WatchAndResize
def self.resizeOnly(argv)
images = Dir.glob("./assets/images/**/*.{jpg,JPG,jpeg,JPEG,png,PNG}")
puts "Checking and resizing './assets/images' if necessary withOUT watching files."
STDOUT.flush
start = Time.now
Parallel.each(images) do |source_path|
destinations = generate_destinations(source_path.gsub("assets/images/", ""), [320, 640, 844, 1208, 1688], "./public", "./assets/images")
min_width_path = destinations[0][1]
#puts "processing: #{source_path}, mtimes: #{File.mtime(min_width_path)} ... #{File.mtime(source_path)}"
puts "checking: #{source_path}"
if (not File.file?(min_width_path)) || (File.mtime(min_width_path) < File.mtime(source_path))
resize_image(source_path.gsub("assets/images/", ""), [320, 640, 844, 1208, 1688], "./public", "./assets/images")
end
#puts "destinations: #{min_width_path}"
#STDOUT.flush
end
delta = Time.now - start
puts "Checked and resized './assets/images' if necessary in #{delta} seconds."
STDOUT.flush
end
def self.awesome(argv)
images = Dir.glob("./assets/images/**/*.{jpg,JPG,jpeg,JPEG,png,PNG}")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment