Skip to content

Instantly share code, notes, and snippets.

@sarupbanskota
Last active August 29, 2015 14:07
Show Gist options
  • Save sarupbanskota/4ed45e22633d754878d8 to your computer and use it in GitHub Desktop.
Save sarupbanskota/4ed45e22633d754878d8 to your computer and use it in GitHub Desktop.
#! /usr/local/bin/ruby -w
# Sarup Banskota, 1 December 2014
require 'phototrim/version'
require 'RMagick'
include Magick
class Phototrim
def self.trim(max_size, root_dir)
Dir.foreach(root_dir) do |subdir|
unless subdir == "." or subdir == ".."
print "Processing images within " + subdir.to_s + "\n"
Dir.foreach(File.join(root_dir, subdir)) do |victimfile|
unless victimfile == "." or victimfile == ".." or File.extname(victimfile) == ".svg"
print "Processing file " + victimfile + "\n"
victim = ImageList.new(File.join(root_dir, subdir, victimfile))
if victim.columns > max_size
print victimfile.to_s + " is beyond " + max_size.to_s + "px wide, scaling down.. \n"
victim = victim.scale(max_size.to_f/victim.columns)
print "Scaled down " + victimfile.to_s + ".\n"
victim.write(File.join(root_dir, subdir, victimfile))
end
end
end
end
end
print "Done! \n"
end
end
#! /usr/local/bin/ruby -w
# Sarup Banskota, 1 December 2014
require 'phototrim/version'
require 'RMagick'
include Magick
class Phototrim
def self.trim(max_size, root_dir)
Dir.foreach(root_dir) do |subdir|
unless subdir == "." or subdir == ".."
print "Processing images within " + subdir.to_s + "\n"
Dir.foreach(File.join(root_dir, subdir)) do |victimfile|
unless victimfile == "." or victimfile == ".." or File.extname(victimfile) == ".svg"
print "Processing file " + victimfile + "\n"
victim = ImageList.new(File.join(root_dir, subdir, victimfile))
if victim.columns > max_size
print victimfile.to_s + " is beyond " + max_size.to_s + "px wide, scaling down.. \n"
victim = victim.scale(max_size.to_f/victim.columns)
print "Scaled down " + victimfile.to_s + ".\n"
victim.write(File.join(root_dir, subdir, victimfile))
end
end
end
end
end
print "Done! \n"
end
end
= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
= f.check_box :sponsoring_needed
Sponsorship Needed
= f.label :email
= f.email_field :email, placeholder: current_user.email, required: "required"
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
Currently waiting confirmation for: #{resource.unconfirmed_email}
= f.label :password
%i (leave blank if you don't want to change it)
= f.password_field :password, autocomplete: "off"
= f.label :password_confirmation
= f.password_field :password_confirmation, autocomplete: "off"
= f.label :current_password
%i (we need your current password to confirm your changes)
= f.password_field :current_password, autocomplete: "off", required: "required"
= f.submit "Update"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment