Skip to content

Commit

Permalink
made script aware of ~ipad/~iphone device modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimaryFeather committed Mar 7, 2012
1 parent 80774aa commit 9496558
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions sparrow/util/texture_scaler/scale_textures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Sparrow
#
# Created by Daniel Sperl on 09.07.2010
# Copyright 2010 Incognitek. All rights reserved.
# Copyright 2012 Gamua. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the Simplified BSD License.
Expand Down Expand Up @@ -82,11 +82,14 @@
File.makedirs target_path
end

purge_regex = /(#{options.purge_suffix})(~iphone|~ipad)?/
device_regex = /((~iphone|~ipad)?\.\S+)$/

images.each do |image|
extname = File.extname(image.image_filename)
basename = File.basename(image.image_filename, extname)
basename.gsub!(options.purge_suffix, "") if basename.end_with? options.purge_suffix
fullpath = File.join(target_path, basename + options.append_suffix + extname)
basename = File.basename image.image_filename
basename.gsub!(purge_regex, '\2') # remove suffix, e.g. img@2x~ipad.png -> img~ipad.png
basename.gsub!(device_regex, options.append_suffix + '\1')
fullpath = File.join(target_path, basename)

image.resize "#{options.scale * 100}%"
image.append_to_operators 'filter', 'Box' if (options.scale == 0.5 || options.scale == 0.25)
Expand Down

0 comments on commit 9496558

Please sign in to comment.