Created
October 27, 2017 17:42
-
-
Save mikka2061/c43c9692f5369b66f43c0cc9640f01ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'listen' | |
require 'skeptick' | |
require 'pp' | |
include Skeptick | |
uploads_dir = "/u/files/" | |
originals = "uploads/" | |
sizes = { | |
"small" => { | |
"location" => "small/", | |
"size" => "300x" | |
}, | |
"medium" => { | |
"location" => "med/", | |
"size" => "600x" | |
}, | |
"web" => { | |
"location" => "web/", | |
"size" => "900x" | |
} | |
} | |
listener = Listen.to(uploads_dir+originals) do |added| | |
sizes.each { |size,data| | |
if (added[0] != nil) | |
addfile = File.basename(added[0]) | |
from = uploads_dir+originals+addfile | |
to = uploads_dir+data["location"]+addfile | |
make = convert(from, to: to) do | |
set :scale, data["size"] | |
end | |
make.run | |
end | |
} | |
end | |
listener.start # not blocking | |
sleep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment