Skip to content

Instantly share code, notes, and snippets.

@rednebmas
Created June 10, 2018 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rednebmas/8de7fea0c54dd792cea03ec998f3442f to your computer and use it in GitHub Desktop.
Save rednebmas/8de7fea0c54dd792cea03ec998f3442f to your computer and use it in GitHub Desktop.
iOS resize script
#!/usr/bin/env python3
import os
import sys
from subprocess import call
if len(sys.argv) == 1:
print("Usage:\n ios-resize filename @3x_size_optional_param (32x32)")
sys.exit()
img_full_path = sys.argv[1]
img_path, img_extension = os.path.splitext(img_full_path)
multiplier_path = lambda m: img_path + "@" + m + "x" + img_extension
if len(sys.argv) < 3:
call(["cp", img_full_path, multiplier_path('3')])
else:
call(["convert", img_full_path, "-resize", sys.argv[2], multiplier_path('3')])
call(["convert", multiplier_path('3'), "-resize", "66%", multiplier_path('2')])
call(["convert", multiplier_path('3'), "-resize", "33%", multiplier_path('1')])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment