Permalink
Browse files

Tidied up a bit

  • Loading branch information...
1 parent 954cd57 commit a2afed6936299f847e9aff1ef1d3ad458f3d4ad3 @jimwhimpey committed Feb 21, 2012
Showing with 25 additions and 21 deletions.
  1. +16 −0 config-example.rb
  2. +0 −5 ftp-example.rb
  3. +9 −16 resize.rb
View
@@ -0,0 +1,16 @@
+# Where images are stored between resizing and uploading
+# Not really important, they're deleted after upload
+$tmp_dir = "tmp/"
+
+# Define the largest width we want for each size
+$size_small = "500"
+$size_large = "1200"
+
+# FTP information for the uploads
+$ftp_host = "example.com"
+$ftp_username = ""
+$ftp_password = ""
+$ftp_path = "/example"
+
+# The HTTP path that will point to the images
+$http_path = "http://example.com/example"
View
@@ -1,5 +0,0 @@
-# FTP information for the uploads
-$ftp_host = "example.com"
-$ftp_username = "example"
-$ftp_password = "example"
-$ftp_path = "/example/example" # http://example.com/example/example
View
@@ -1,18 +1,11 @@
require 'net/ftp'
require 'mini_magick'
-require './ftp.rb'
-
-# Define sizes
-small = "500"
-large = "1200"
-
-# Where images are stored before they're uploaded
-tmp_dir = "/Users/jimwhimpey/Desktop/"
+require './config.rb'
# Grab the image
if (ARGV[0] != nil) then
- path = ARGV[0]
- image = MiniMagick::Image.open(path)
+ local_path = ARGV[0]
+ image = MiniMagick::Image.open(local_path)
else
p "You must pass in an image path"
return
@@ -28,18 +21,18 @@
# Filenames and paths
large_name = title + "-large." + image[:format].downcase
small_name = title + "-small." + image[:format].downcase
-large_path = tmp_dir + large_name
-small_path = tmp_dir + small_name
+large_path = $tmp_dir + large_name
+small_path = $tmp_dir + small_name
# Do the large resizing (if it's wider than the large)
-if (image[:width] > large.to_i) then
- image.resize(large)
+if (image[:width] > $size_large.to_i) then
+ image.resize($size_large)
end
image.write(large_path)
# Do the small resizing (if it's wider than the small)
-if (image[:width] > small.to_i) then
- image.resize(small)
+if (image[:width] > $size_small.to_i) then
+ image.resize($size_small)
end
image.write(small_path)

0 comments on commit a2afed6

Please sign in to comment.