Skip to content

Instantly share code, notes, and snippets.

@evadecker
Last active August 18, 2017 02:08
Show Gist options
  • Save evadecker/392fb181bf323bb0bc62e1da79efc4ea to your computer and use it in GitHub Desktop.
Save evadecker/392fb181bf323bb0bc62e1da79efc4ea to your computer and use it in GitHub Desktop.
Join normal and retina images into a multi-page TIFF.
import os
exportdir = 'new'
# Create a 'new' directory to put merged files
os.system('mkdir ' + exportdir)
# Iterate over files and combine using tiffcp
for file in os.listdir('.'):
if file.endswith('@2x.tiff'):
continue
if file.endswith('.tiff'):
filename = os.path.splitext(file)[0]
# Take file + file@2x and create new.tiff, remove old files, rename new.tiff to original filename.tiff
# tiffcp $file.tiff $file@2x.tiff new.tiff && rm $file.tiff && rmmv new.tiff $file.tiff
os.system('tiffcp ' + filename + '.tiff ' + filename + '@2x.tiff new.tiff && rm ' + filename + '.tiff && rm ' + filename + '@2x.tiff && mv new.tiff ' + exportdir + '/' + filename + '.tiff')
# Move files in 'new' back to default directory
os.system('mv ' + exportdir + '/* .')
# Delete 'new' directory
os.system('rmdir ' + exportdir)
print "TIFFs joined successfully"
@evadecker
Copy link
Author

Instructions:

  1. Export your single-page TIFFs from Sketch into a single directory. They should be named identically, like {filename}.tiff and {filename}@2x.tiff.
  2. Download tiffjoin.py and place it in the export directory.
  3. Open terminal.
  4. Navigate to the directory with all the images using cd [drag the directory into terminal]
  5. In terminal, run python tiffjoin.py
  6. You should now have multi-page TIFFs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment