Skip to content

Commit

Permalink
increase thumbnail sizes and change IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdeitke committed Jun 14, 2019
1 parent 37ebf78 commit 1a7ea9e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pdftothumbs.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# go over all pdfs in NIPS and use imagemagick to convert
# go over all pdfs and use imagemagick to convert
# them all to a sequence of thumbnail images
# requires sudo apt-get install imagemagick
# or can be installed with brew install imagemagick

import os

relpath = "nips25offline/content/"
relpath = "content/"
allFiles = os.listdir(relpath)
pdfs = [x for x in allFiles if x.endswith(".pdf")]

for i,f in enumerate(pdfs):
paperid = f[9:-4]
paperid = f[:-20]
fullpath = relpath + f

print "processing %s, %d/%d" % (paperid, i, len(pdfs))
print("processing %s, %d/%d" % (paperid[:5], i, len(pdfs)))

# this is a mouthful...
# take first 8 pages of the pdf ([0-7]), since 9th page are references
# tile them horizontally, use JPEG compression 80, trim the borders for each image
cmd = "montage %s[0-7] -mode Concatenate -tile x1 -quality 80 -resize x230 -trim %s" % (fullpath, "thumbs/" + f + ".jpg")
print "EXEC: " + cmd
# colorspace was added because a few PDFs displayed with a black background
cmd = "montage %s[0-7] -mode Concatenate -colorspace sRGB -tile x1 -quality 80 -resize x345 -trim %s" % (fullpath, "thumbs/" + paperid + ".jpg")
print("EXEC: " + cmd)
os.system(cmd)


# an alternate, more roundabout alternative that is worse and requires temporary files, yuck!
#cmd = "convert -thumbnail x200 %s[0-7] test.png" % (fullpath, )
Expand Down

0 comments on commit 1a7ea9e

Please sign in to comment.