So I created synothumb.sh a while ago to quickly create thumbnails for my Synology DS211j NAS box. Unfortunately many people wanted something that would run easily on a mac so i have just rewritten this to run using python and the PIL module (how to install PIL).

You’ll need to mount the remote drive via nfs(network file share) and not afp(apple file protocol)

Here’s the code. I strongly suggest reading through it and maybe making changes to suit your own needs. Link to Code (https://github.com/phillips321/synothumbs – dont copy/paste due to indents)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# sudo mount_nfs -P 192.168.0.2:/volume1/photo /Users/phillips321/nfsmount
import os,sys,Image
try:
    rootdir=sys.argv[1]
except:
    print "Usage: %s directory" % sys.argv[0]
    sys.exit(0)
imageList=[]

# Finds all images of type jpg,png,jpeg,tif,bmp
for path, subFolders, files in os.walk(rootdir):
    for file in files:
        if os.path.splitext(file)[1].lower() == ".jpg" or ".png" or ".jpeg" or ".tif" or ".bmp":
            if "@eaDir" not in path:
        if file != ".DS_Store": imageList.append(os.path.join(path,file))

xlName="SYNOPHOTO:THUMB_XL.jpg" ; xlSize=(1280,1280) #XtraLarge
lName="SYNOPHOTO:THUMB_L.jpg" ; lSize=(800,800) #Large
bName="SYNOPHOTO:THUMB_B.jpg" ; bSize=(640,640) #Big
mName="SYNOPHOTO:THUMB_M.jpg" ; mSize=(320,320) #Medium
sName="SYNOPHOTO:THUMB_S.jpg" ; sSize=(160,160) #Small

for imagePath in imageList:
    imageDir,imageName = os.path.split(imagePath)
    thumbDir=os.path.join(imageDir,"@eaDir",imageName)
    if os.path.isdir(thumbDir) != 1:
    try:os.makedirs(thumbDir)
    except:continue
    image=Image.open(imagePath)
    if os.path.isfile(os.path.join(thumbDir,xlName)) != 1:
        print "Now working on %s : %s" % (imageName,xlName)
        image.thumbnail(xlSize, Image.ANTIALIAS)
        image.save(os.path.join(thumbDir,xlName))
        print "Now working on %s : %s" % (imageName,lName)
        image.thumbnail(lSize, Image.ANTIALIAS)
        image.save(os.path.join(thumbDir,lName))
        print "Now working on %s : %s" % (imageName,bName)
        image.thumbnail(bSize, Image.ANTIALIAS)
        image.save(os.path.join(thumbDir,bName))
        print "Now working on %s : %s" % (imageName,mName)
        image.thumbnail(mSize, Image.ANTIALIAS)
        image.save(os.path.join(thumbDir,mName))
        print "Now working on %s : %s" % (imageName,sName)
        image.thumbnail(sSize, Image.ANTIALIAS)
        image.save(os.path.join(thumbDir,sName))

Leave a Reply