Skip to content

Instantly share code, notes, and snippets.

@scottdavis
Created November 19, 2010 19:50
Show Gist options
  • Select an option

  • Save scottdavis/707029 to your computer and use it in GitHub Desktop.

Select an option

Save scottdavis/707029 to your computer and use it in GitHub Desktop.
Down convert images for older iphones
def get_images
Dir['*.{png, gif, jpeg}']
end
def image_is_2x?(image)
image.include?('@2x')
end
get_images.each do |image|
old_image = image
unless image_is_2x? image
parts = image.split('.')
newname = "#{parts[0]}@2x.#{parts[1]}"
puts "Renaming #{image} to @2x"
system("mv #{image} #{newname}")
image = newname
end
puts "Converting #{image} to 50% as #{old_image}"
system("convert #{image} -filter Lanczos -resize 50% #{old_image}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment