Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save augustorsouza/7979918 to your computer and use it in GitHub Desktop.
Save augustorsouza/7979918 to your computer and use it in GitHub Desktop.
Sample helper script to create images generated by dragging pixelmator's layers to finder from @2x resolution to normal resolution and facilitates its use in iOS projects
# Add ...@2x.png string end to those exported using Pixelmator
Dir.glob("./*2x.png").each do |old_path|
next if old_path =~ /@2x.png/
ext = File.extname(old_path)
filename = File.basename(old_path, ext)
new_filename = filename.sub("2x", "@2x") + ext
File.rename(old_path, new_filename)
end
# Use image magick to generate hald sized images
Dir.glob("./*@2x.png").each do |full_image|
half_image = full_image.sub("@2x", "")
system "convert #{full_image} -resize 50% #{half_image}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment