Permalink
Browse files

Added support for passing in a class name

  • Loading branch information...
1 parent 0efa75e commit b67a6201b3db6e090fa41391072b001c585cb46c @jimwhimpey committed Feb 21, 2012
Showing with 12 additions and 3 deletions.
  1. +2 −2 readme.md
  2. +10 −1 resize.rb
View
@@ -1,14 +1,14 @@
# A Very Simple Ruby Command Line Image Resizer
-Takes a local image path and (optionally a title), creates a small version, creates a larger version, uploads them via FTP, returns HTML of the smaller image linking to the larger image, automatically copies it to your pasteboard.
+Takes a local image path and (optionally a title, optionally a class), creates a small version, creates a larger version, uploads them via FTP, returns HTML of the smaller image linking to the larger image, automatically copies it to your pasteboard.
Handles any image type ImageMagick will take. Smart enough to not resize images *up* if they're not big enough but that's where the smart ends. This is a little tool for me to fill a gap [I see](http://valhallaisland.com/blog/2012/octopress/) in the otherwise brilliant [Octopress](http://octopress.org/) blogging software. I hope someone else can also find it useful in some capacity.
## Usage
1. Download this thing.
2. Modify the config and rename it `config.rb`
-3. Run `ruby resize.rb /path/to/image.png "title of image"` (remember that you can drag and drop files onto the command line to paste in the path).
+3. Run `ruby resize.rb /path/to/image.png "optional title of image" "optional-class"` (remember that you can drag and drop files onto the command line to paste in the path).
4. Wait for the files to upload.
5. Markdown is now copied to your pasteboard.
View
@@ -18,6 +18,11 @@
title = Time.now.to_i.to_s
end
+# Check if there's a class
+if (ARGV[2] != nil) then
+ class_name = ARGV[2]
+end
+
# Filenames and paths
large_name = title + "-large." + image[:format].downcase
small_name = title + "-small." + image[:format].downcase
@@ -50,7 +55,11 @@
File.delete(small_path)
# Output the markdown and copy it to the clipboard
-html = "<a href='" + $http_path + "/" + large_name + "'><img src='" + $http_path + "/" + small_name + "' alt='" + title.gsub("\-", " ") + "' /></a>"
+html = "<a href='" + $http_path + "/" + large_name + "'><img src='" + $http_path + "/" + small_name + "' alt='" + title.gsub("\-", " ") + "' "
+if (class_name != nil) then
+ html += "class='" + class_name + "' "
+end
+html += "/></a>"
IO.popen('pbcopy', 'r+') { |clipboard| clipboard.puts html }
print "========================================================\n"
print "The following HTML has been copied to your clipboard\n\n"

0 comments on commit b67a620

Please sign in to comment.