UPDATE: If you’re on a Mac I suggest you use this python script instead.

The Synology Diskstation(DS) devices have a Photo Station application that creates a web based album of folders in your /photos folder.

The DS creates thumbnails for these photos when they are uploaded to the NAS. Unfortunately these devices are using slow low power processors so converting the photos takes some time. Each photo has 5 thumbnails of different sizes, and videos have various conversions applied to them.

What this script does is allow you to use the power of your workstation to do the processing for you.

Requires ImageMagick and ffmpeg, both free and opensource.

As of version 1.0 this now supports videos!

The script can be downloaded from the googlecode page here or you can get a copy via svn:
svn checkout http://synothumbs.googlecode.com/svn/trunk/ synothumbs
Simply browse to the directory you want to process and run the command like so, photos with thumbnails already created will be skipped:

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
phillips321@KubuntuDesktop:~$ synoThumbs.sh test
###########################################################################################################
 Welcome to synoThumb.sh version 1.0
 This script creates the thumbs for a synology
##########################################################
Searching Thumbs For test/IMG_1792.JPG
   -- SYNOPHOTO:THUMB_XL.jpg thumbnail created
   -- SYNOPHOTO:THUMB_L.jpg thumbnail created
   -- SYNOPHOTO:THUMB_B.jpg thumbnail created
   -- SYNOPHOTO:THUMB_M.jpg thumbnail created
   -- SYNOPHOTO:THUMB_S.jpg thumbnail created
Searching Thumbs For test/P3260456.JPG
   -- SYNOPHOTO:THUMB_XL.jpg thumbnail created
   -- SYNOPHOTO:THUMB_L.jpg thumbnail created
   -- SYNOPHOTO:THUMB_B.jpg thumbnail created
   -- SYNOPHOTO:THUMB_M.jpg thumbnail created
   -- SYNOPHOTO:THUMB_S.jpg thumbnail created
Searching video conversions for test/IMG_1812.MOV
   -- processing IMG_1812.MOV
   -- IMG_1812.MOV flv created
   -- processing IMG_1812.MOV
   -- IMG_1812.MOV h264 created
Searching Thumbs For test/IMG_1812.MOV
   -- SYNOPHOTO:THUMB_XL.jpg thumbnail created
   -- SYNOPHOTO:THUMB_L.jpg thumbnail created
   -- SYNOPHOTO:THUMB_B.jpg thumbnail created
   -- SYNOPHOTO:THUMB_M.jpg thumbnail created
   -- SYNOPHOTO:THUMB_S.jpg thumbnail created
Searching video conversions for test/P3260441.AVI
   -- processing P3260441.AVI
   -- P3260441.AVI mp4 created
   -- processing P3260441.AVI
   -- P3260441.AVI mobile mp4 created
Searching Thumbs For test/P3260441.AVI
   -- SYNOPHOTO:THUMB_XL.jpg thumbnail created
   -- SYNOPHOTO:THUMB_L.jpg thumbnail created
   -- SYNOPHOTO:THUMB_B.jpg thumbnail created
   -- SYNOPHOTO:THUMB_M.jpg thumbnail created
   -- SYNOPHOTO:THUMB_S.jpg thumbnail created
##########################################################
 Now log into DSM and reindex your photos
 (Control Panel --> Media Indexing Service --> Re-index)
##########################################################
phillips321@KubuntuDesktop:~$

100 Responses to Creating Thumbnails for the Synology DiskStation PhotoStation

  • bgfildev says:

    Hi and congratulations for this very usefull script.
    any news about a version handling mts file as I have tons of mts file and this so long on my ds212j ?

  • Excellent work!
    Where can I donate?

    • phillips321 says:

      Thanks for the offer but i enjoy writing code so don’t accept donations…. all i ask is that if you ever develop something you feel is useful that you share it to the community as well. ;-)

  • birger100 says:

    Hey
    I’m getting this error when running the script on the folder “test”
    mkdir: kan ikke oprette katalog ‘test/@eaDir’: Ingen sådan fil eller filkatalog – Danish error msg
    mkdir: unable to create ‘test/@eaDir’: no such file or catalog – English error msg

    I’m able to create other catalogs using mkDir from the terminal, so i would think that I have the correct rights on the NAS..

    Any ideas?

    /Birger

  • Adrian says:

    Hello,
    it work fine as long the files/folders doesn’t contains a blank within theri name… If so then:


    — SYNOPHOTO:THUMB_S.jpg thumbnail created
    Searching Thumbs For /Volumes/photos//Friends/a b c/P1050705.jpg
    mkdir: /Volumes/photos//a b c/@eaDir/P1050705.jpg: Invalid argument
    chmod: /Volumes/photos//a b c/@eaDir/P1050705.jpg: Invalid argument
    convert: unable to open image `/Volumes/photos//a b c/@eaDir/P1050705.jpg/SYNOPHOTO:THUMB_XL.jpg’: Invalid argument @ error/blob.c/OpenBlob/2643.
    — SYNOPHOTO:THUMB_XL.jpg thumbnail created

    Any idea how to fix this?

    Configuration/Using:
    DS213air, ImageMagick-6.8.8 on MAC OS X 10.9
    Thank you.

  • Are there any plans to add the MPG support as written in ToDo? Thanks!

    • phillips321 says:

      Adding MPG support is relatively easy but it’s just a case of figuring out the command required for ffmpeg. Unfortunately i just don’t have the time to look into this at present but if someone can let me know the ffmpeg command required for the thumbs and conversions i’ll integrate it into the script.

  • Paul says:

    Brian mentioned “ACDSee” in his July 9, 2012 post. How would one modify the script to skip all the [Originals] folders that ACDSee creates? They don’t need to be indexed nor viewable in Photo Station.

    Disk Station 112; Photo Station 6.0-2626; DSM 4.3-3776

  • tbeer says:

    Hi, I experiencing the following problem:
    All my thumbs (about 30 k photos of diverse formats such as DNGs, jgps) etc. have been created successfully. Nevertheless, the Synology thumb creation (synomkthumd) immediately starts when I start the Synology Photo Station afterwards. Do you have any ideas?
    Thank you so much.

    • phillips321 says:

      Hmm, have you tried turning off photo station. Indexing. Then turning back on photo station? What about the file permissions? Photo station i believe needs RW to the @eaDir folders. SSH in an chmod 666 the folders.

      • tbeer says:

        What do you mean with “indexing”? Using the DSM? I recognized that DSM 4.3 uses “SYNOPHOTO_THUMB_*” instead of “SYNOPHOTO:THUMB_*”. Maybe I should rename alle the thumbs?!? I’m a little confused … Thanks again for your support.

        • phillips321 says:

          Hmm, that’s good to know. I’m currently running 4.2, will update now and check by creating a new pictures folder. If that is that case i’l write a quick bash script to rename them all. (Although surely the devs wouldn’t force people to create all the thumbnails again???)

          • tbeer says:

            After the indexing of the DSM was done I have started the Photo Station. The “synomkthumd” and “synoindexd” (also the exiv2 script) are still heavily consuming CPU (see extract of my top command below). Where can I see (log, etc.) what the synomkthumd is acutally doing? The DSM does not show any thumbnail creation activities (there is no small “wheel” in the upper right corner right behind the option menu).

            Extract of “top”:
            ———————
            19521 5566 admin S 35344 6.9 7.1 postgres: admin photo [local] idle
            19264 1 root R N 37796 7.3 3.3 /usr/syno/bin/synomkthumbd
            19241 1 root S N 39616 7.7 2.7 /usr/syno/sbin/synoindexd
            25191 25192 sh -c /usr/syno/bin/exiv2 -g Xmp.dc.description -Pt “/volume1/photo/IMG_27012003/IMGP3554.JPG”

            P.S. If you need a renaming script I already have one.

            Thanks again.

          • phillips321 says:

            I think the 30k of photos you have still need indexing and that’s what’s taking so long? I uploaded about 5k photo’s and it still took over night to index. (Maybe only an hour or so but it was left overnight so not sure of exact time 1

            I think best bet would be to give it chance to index (it adds them to a postgres db) and then see how it gets on.

            I’ve just upgraded to 4.3 and it still works fine using the : in the filename. I guess it’s backward compatible :-)

          • tbeer says:

            hm, its really strange. I have removed all my @eaDir directories and have created all the thumbs a second time. The indexer is still running but I expect that I couldn’t solve my problem. When I look into var/log/messages I see numerous error messages of the form:
            “synoindexd: index_image_resolution_get.c:628 Cannot open the file: /volume1/photo/2006/06/WM2006/Dortmund/@eaDir/GER_POLEN_Dortmund044.JPG/SYNOPHOTO_THUMB_XL.jpg! ” It seems that the indexer is looking for “SYNOPHOTO_” instead of “SYNOPHOTO:”. I assume you didn’t have such error messages in you “var/log/messages” after upgrading to DSM 4.3 right?

  • Pingback: synothumb.py – Only does pics but is for OS X | phillips321.co.uk

  • Tim says:

    Hi phillips321

    Thank you very much for sharing this script. Added -o -name “*.NEF” -o -name “*.nef” to f_pics() to allow processing of Nikon raw format. For convert to work properly, ufraw-batch needs to be installed.

    sudo apt-get install ufraw-batch

    Thanks you very much!!!!
    Tim

  • gyphon says:

    Any news as to when you will post your updated script? I don’t mount via NFS so the @ directories don’t show up from windows. Maybe I’m doing something wrong…

  • Cavan says:

    Nice work Phillip! Would you be able to implement multi-core support?
    Something like NUMCPU=”$(grep ^processor /proc/cpuinfo | wc -l)” then use that that number to know how many thumbs can be processed at a time?

    Either way, great script. :)

  • Protivoro says:

    The script run great!! but i have lot of videos in .mpg format. How i could generate thumbs for that video type?

  • Hi,

    I have the same issue already reported by (for instance) pepeoriginal and Matthew Hiatt, but I don’t see any solution here within the comments.
    I’m running DSM4.0 on a DS210j, 20000+ images yet to process.
    The script is running on a fairly recent Linux Mint installation. Imagemagik and ffmpeg freshly installed.
    NAS mounted as per Lamunique3 suggestion (slight change in the code, in my case: sudo mount -t cifs //192.168.2.10/photo /mnt/photo -o username=user,password=pass,domain=WORKGROUP).
    NFS, SMB, FTP et al are all enabled.
    NAS can be browsed and read/write is ok.
    I’ve tried to create the thumbs for a test folder, but got the already reported error.
    Also, I can’t find anywhere the @eaDir folders, even in the folders that were already processed by the NAS itself. Where should they be?

    So, any suggestion on how to solve this problem?
    Thanks for your precious help!

    Francesco

    • phillips321 says:

      So your mounting using smb, hence the cifs in your fstab line.

      Install nfs-common and use nfs as the tool states.

      • Ok, thanks.
        I think I tried already mounting the partition with nfs, but reading your answer makes me think that I might have done it wrongly. I’ll give it a try again and let you know if it works.
        Thanks!

        • phillips321 says:

          Try mount -t nfs

          To find the names of the nfs shares try

          showmount -e 192.168.2.10

          • mount -t nfs does not work.
            I’ll need to check the nfs-common, which might be missing and then I’ll go with something like:
            sudo mount -o soft,intr,rsize=8192,wsize=8192 192.168.2.10:/photo /nfs
            (google is my friend…. http://is.gd/lMWV9H)

            this should work, I guess…!

            thanks

          • Ok, it did work!
            Thanks a trillion for the script! it took ~12h to create thunmbnails for 20000+ images, waaaaay less than on my DS210j.
            the only point now is that -accodering to the nas- I still have 3 images to be indexed, even after a re-run of the script. And those 3 apparently are not being processed byt hte nas: after 5hours the nas was still showing 3 images left. Do you have any idea on how to trace back those images so that I can -evenatully- delete them ans stop the nas from munching endlessly?
            Thanks
            Francesco

          • Thought it migh be useful for someone else if I list the procedure I followed.
            This wors for DSM4.0 and DSM4.1, both tested on my DS210j.
            1. in your linux box, install nfs-common
            2. in your DSM control panel, go to NFS management and create the appropriate rules for your PC. In my case, the NAS is on 192.168.2.10. The PC is on 192.168.2.40. The reule I’ve created allows read/write access to 192.168.2.40. It works with “no mapping” and with “mapping to root account” as well. It didn’t work by mapping the hostname, I had to fill in the real IP address.
            3. on your PC:
            a) shwomount -e 192.168.2.10 (to check that the PC ip address is correctly allowed to access)
            b) sudo mkdir /mnt/photo
            c) cd /mnt
            d) sudo cp /path-to-the-script/synoThumbs.sh .
            e) sudo chmod u+x synoThumbs.sh
            f) sudo mount -o soft,intr,rsize=8192,wsize=8192 192.168.2.10:/volume1/photo /mnt/photo
            g) ./synoThumbs.sh photo
            4. the script seems to hang doing nothing, but I guess it is just looking through your files. After a while it will start showing thumbnails already created or creating the new thumbs.
            5. relax, take your time and say thanks to Phillips312!!!!

            Hope it might help somebody.
            Francesco

          • paddy says:

            hi,
            have a ds114 and the v3 script hangs in line 23 ,.. (DSM 4.3)
            maybe you could check it,.. maybe cpu problems?

            version 2 works without an error

  • My apologies in advance — I’m a Linux idiot….

    I’m getting errors it looks like on every single image so far. I’m wondering if the file names that have spaces in them are the problem or if something else is going on.

    –SYNOPHOTO:THUMB_L.jpg thumbnail created
    convert.im6: Empty input file ‘photo/Gatlinburg – Judes – Sarah Camera/@eaDir/IMG_6321.jpg/SYNOPHOTO:THUMB_L.jpg’ @ error/jpeg.c/JPEGErrorHandler/316.
    convert.im6: unable to open image ‘photo/Gatlinburg – Judes – Sarah Camera/@eaDir/IMG6321.jpg/SYNOPHOTO;THUMB_B.jpg’: Permission denied @ error/blob.c/OpenBlob/2638

    There is one of these blocks for each – it says XL created, then error xl, l, b, m, and s….

    Any ideas where I’ve gone wrong?
    Thanks again for your work….

    • There’s a huge detail I forgot….and this is a totally blame-the-user-who-is-me thing:

      I saw the article the Synology forums for using Windows to make the thumbnails….and got really excited and downloaded it….and only after I started running it, did I notice the instruction I hadn’t read about doing this in a location other than /photo — and have not finished it sense.

      I was trying to run this code in a virtualbox of ubuntu, if that’s helpful.

      Thanks for any assistance you can provide!

  • Xenios says:

    HI Philip and thx for this great script! Creating thumbs for my whole collection of about 25.000 photos on my new DS213 took only one night, I think the poor little DS wouldn’t have finished until next christmas… ;-) Great work, thank you!

  • Alexis says:

    Thanks for sharing this script !
    I’ve created the thumbnails for my 20K+ photo library in a couple hours rather than days (weeks ?!) on my NAS..

    Greetings from France,
    -Alexis.

  • BobThai says:

    Following Lamunique3′s instructions, when I get to mount command I receive the following errors:

    bob@bob-virtual-machine:/mnt$ sudo mount -t cifs //192.168.1.20 /mnt/photo -o username=bob,password=mypass,domain=WORKGROUPmount: wrong fs type, bad option, bad superblock on //192.168.1.20,
    missing codepage or helper program, or other error
    (for several filesystems (e.g. nfs, cifs) you might
    need a /sbin/mount. helper program)
    In some cases useful info is found in syslog – try
    dmesg | tail or so

    Phillip can you advise what is wrong? I’m a noob with linux & mounting. My photos are stored in default \photo directory on synology. I’m running this on a ubuntu vm. Why does it say wrong fs type, etc.?

  • Anant says:

    I have a 2010 Macbook pro, running Mountain Lion and my NAS is connected to a router.

  • Anant says:

    Hello, I just bought a DS413j and uploaded 9000 pictures to it and saw that it is taking too long for the thumbnail conversion. I searched online and came upon this blog. I am completely new to synology and have no idea how to run scripts. I am wondering if someone can be kind enough to put a step by step guide on what am I suppose to do. I do not even know how to install the software needed to run the Script. Please, any help will be greatly appreciated.

    • phillips321 says:

      The script must be run on the PC in order to use the PCs processing power. This script is designed for Linux, not for Windows or MacOSX (although it should work on OSX with the correct libraries installed)

  • Jimmy says:

    Hi, I just used this script successfully on Max OS X 10.6.8 with a Synology DS 212 J.
    First, you need to mount the photo shared folder as a NTFS mount. For this you need to setup the NFS share on the Synology box (control panel -> win/mac/nfs -> nfs service) then and give liberal access to this NFS share (shared folder -> photo -> privilege -> nfs privilege). Then you can mount it ( sudo mount_nfs //SYNO_IP/photo /tmp/photo), then copy the script to /tmp/photo and run it. All set. The script hanged a few times for me so I had to CTRL-C it and restart. Thanks for the script!

    • Anant says:

      Hello, i have been able to install ImageMagic and ffmpeg and i followed your instructions regarding NFS share. But i am not able to mount the folder in terminal. Can you please explain this for me a little better. I am completely newbie to scripts.

  • Rudie says:

    I just bought a synology DS112J and copied 30.000 photos to it. Since the amount of photos and the “slow” system this script is a must for me. So, a big thanks!

    But it’s stil slow :-)

    I think i found some room for optimalisation. The convert command accepts one input and multiple outputs. So the convert command only once has to read and decompress one input file. http://www.imagemagick.org/Usage/files/#write

    The downside, all thumbs must be created or none of them, but i think its not a big deal.

  • Markus says:

    Hey!

    What about using gnu parallel? You can ship it with your code. Just use “sem” inside your for loops. That’s it!

    http://www.gnu.org/software/parallel/man.html

  • Iamunique3 says:

    I’ve successfully managed to run the script, but it is surprisingly… slow. I run it within Ubintu 12.04.1 LTS 64bit Live CD. It takes 30 second to procuce “L” thumbnail + 30 sec fo “M” thumbnail – S, B and XL aren’t created at all. My hardware is 2nd gen mobile i7 (2 core) + 8GB of ram, but it seems it’s not fully utilized since System Monitor shows CPU use of about 10-20% and 900 MB of RAM occupied. What might be the cause?

    • phillips321 says:

      The script is wrote single threaded so it will only use 1 core, if you have 4 cores you’ll only see CPU 25% utilized. Disk access is the limiting factor here, not CPU or RAM.

      I’ll look to create a LiveCD in the future that is optimised for the conversion.

      • Iamunique3 says:

        Hmm, sad to hear that. I’m afraid I won’t be able to improve disk access anymore, since I’m already attached by wire and nobody else is using my DS. But I wonder – how come others were able to cope with all their photos in minutes, not hours? Is live CD doing such a great difference? I’ve also tried to run the script from via Ubuntu@virtualbox, with same results unfortunately :-(

        • phillips321 says:

          My image conversions are pretty quick and i’m on a AMD x6 1055T@3.8GHz, SSD, 8Gb. Files are mounted via NFS over gigabit.

          A VM should be able to hardness the full speed of the host machine and should perform better than a LiveCD (the VM wasnt a LiveCD by any chance was it?)

          • Iamunique3 says:

            So I have a weaker CPU (Intel Core i7-2620M @ 2.70GHz passmark score of ~4000 while yours gets ~5000) plus only a 100M router.

  • Usr says:

    Hey there!

    I’m new to telnet, ssh, shell scripts and stuff like that..
    Would you please give an introduction for those like me?

    I don’t know where to start….

    Unfortunaly I copied synoThumbs.sh into a Folder on my Harddrive of my Mac.
    Then I tried to start the Script by using “exec sh synoThumbs.sh”

    The Script gives errormessages, that it need a direction.
    After creating a folder in the same direction it throws no exceptions, and nothing happens..

    An introduction would be great! :)
    Thanks!

    • Iamunique3 says:

      1. Run a Linux live CD (http://www.ubuntu.com/download/desktop)
      2. Run a terminal and paste (one line each time):

      sudo apt-get install subversion
      svn checkout http://synothumbs.googlecode.com/svn/trunk/ synothumbs
      sudo mv synothumbs/synoThumbs.sh /mnt
      cd /mnt
      chmod u+x synoThumbs.sh
      sudo mkdir /mnt/photo
      sudo mount -t cifs //192.168.1.1 /mnt/photo -o username=user,password=pass,domain=WORKGROUP
      ./synoThumbs.sh photo

      You need to adapt few places here: first you need to paste you’s Synology’s IP instead of 192.168.1.1, second: name of the folder/share where photos are stored on Synology (photo in this example), third: your Synology username, password and domainname.

      Good luck!

      • phillips321 says:

        The only issues with using a live CD is that the system will be running from RAM… maybe i should develop a custom built live CD to do the conversion process?

        • Iamunique3 says:

          Lightweight live linux would be most welcome :-) But what about performance? My attempts with Ubuntu Live CD were so bad, that they almost defeated the purpose – conversion on PC takes almost as much as conversion @ DS :(

  • Brian A in SD says:

    For Windows users:

    I was able to get NetDrive to work. Enable WebDav on your NAS, open 5005 & 5006 ports on your router, and connect via Net Drive. I can see thumbnails of all of my photos, without the extra @eaDir directories, or any homemade script.

    On NetDrive, click on site, then click Advanced. Click Use Https
    Be sure you have the latest version of NetDrive installed (free)

  • Sunil says:

    Worked like a charm. Thanks a lot.

  • pepeoriginal says:

    Hello,

    I try to execute the script over my NAS 4.0 trough Ubuntu, but I receive stranges messages, and after execution, the NAS still creating all the Thumbs process.

    I give you part of message for one picture, If you can help me.

    Thanks,
    ————————
    Searching Thumbs For /mnt/NAS/cover/lunis cover.jpg
    convert: no decode delegate for this image format `/mnt/NAS/cover/lunis cover.jpg’ @ error/constitute.c/ReadImage/544.
    convert: no images defined `/mnt/NAS/cover/@eaDir/lunis cover.jpg/SYNOPHOTO:THUMB_XL.jpg’ @ error/convert.c/ConvertImageCommand/3044.
    — SYNOPHOTO:THUMB_XL.jpg thumbnail created
    convert: unable to open image `THUMB_XL.jpg’: No such file or directory @ error/blob.c/OpenBlob/2642.
    convert: no decode delegate for this image format `THUMB_XL.jpg’ @ error/constitute.c/ReadImage/544.
    convert: no images defined `/mnt/NAS/cover/@eaDir/lunis cover.jpg/SYNOPHOTO:THUMB_L.jpg’ @ error/convert.c/ConvertImageCommand/3044.
    — SYNOPHOTO:THUMB_L.jpg thumbnail created
    convert: unable to open image `THUMB_L.jpg’: No such file or directory @ error/blob.c/OpenBlob/2642.
    convert: no decode delegate for this image format `THUMB_L.jpg’ @ error/constitute.c/ReadImage/544.
    convert: no images defined `/mnt/NAS/cover/@eaDir/lunis cover.jpg/SYNOPHOTO:THUMB_B.jpg’ @ error/convert.c/ConvertImageCommand/3044.
    — SYNOPHOTO:THUMB_B.jpg thumbnail created
    convert: unable to open image `THUMB_B.jpg’: No such file or directory @ error/blob.c/OpenBlob/2642.
    convert: no decode delegate for this image format `THUMB_B.jpg’ @ error/constitute.c/ReadImage/544.
    convert: no images defined `/mnt/NAS/cover/@eaDir/lunis cover.jpg/SYNOPHOTO:THUMB_M.jpg’ @ error/convert.c/ConvertImageCommand/3044.
    — SYNOPHOTO:THUMB_M.jpg thumbnail created
    convert: unable to open image `THUMB_M.jpg’: No such file or directory @ error/blob.c/OpenBlob/2642.
    convert: no decode delegate for this image format `THUMB_M.jpg’ @ error/constitute.c/ReadImage/544.
    convert: no images defined `/mnt/NAS/cover/@eaDir/lunis cover.jpg/SYNOPHOTO:THUMB_S.jpg’ @ error/convert.c/ConvertImageCommand/3044.
    — SYNOPHOTO:THUMB_S.jpg thumbnail created
    ————————————————–

    Regards,

    José

    • phillips321 says:

      First error is: no decode delegate for this image format

      The rest of the errors are because the first convert failed.

      Can you send me a copy of an example image that it fails on and also what version of imagemagic are you running?

      • Gildas says:

        Same problem for me… is there a solution ?

        — SYNOPHOTO:THUMB_XL.jpg thumbnail created
        convert: pas de délégué pour décoder ce format d’image `THUMB_XL.jpg’ @ error/constitute.c/ReadImage/532.
        convert: nom de fichier d’image absent `/media/diskstation/2004/@eaDir/IMG_2032.jpg/SYNOPHOTO:THUMB_L.jpg’ @ error/convert.c/ConvertImageCommand/3011.
        — SYNOPHOTO:THUMB_L.jpg thumbnail created
        convert: pas de délégué pour décoder ce format d’image `THUMB_L.jpg’ @ error/constitute.c/ReadImage/532.
        convert: nom de fichier d’image absent `/media/diskstation/2004/@eaDir/IMG_2032.jpg/SYNOPHOTO:THUMB_B.jpg’ @ error/convert.c/ConvertImageCommand/3011.
        — SYNOPHOTO:THUMB_B.jpg thumbnail created
        convert: pas de délégué pour décoder ce format d’image `THUMB_B.jpg’ @ error/constitute.c/ReadImage/532.
        convert: nom de fichier d’image absent `/media/diskstation/2004/@eaDir/IMG_2032.jpg/SYNOPHOTO:THUMB_M.jpg’ @ error/convert.c/ConvertImageCommand/3011.
        — SYNOPHOTO:THUMB_M.jpg thumbnail created
        convert: pas de délégué pour décoder ce format d’image `THUMB_M.jpg’ @ error/constitute.c/ReadImage/532.
        convert: nom de fichier d’image absent `/media/diskstation/2004/@eaDir/IMG_2032.jpg/SYNOPHOTO:THUMB_S.jpg’ @ error/convert.c/ConvertImageCommand/3011.
        — SYNOPHOTO:THUMB_S.jpg thumbnail created

      • Fischelsberger says:

        I have also the same problem…

        Searching Thumbs For photo/2012/2012_07_28/2012_07_28 (18).JPG
        convert: no decode delegate for this image format `photo/2012/2012_07_28/2012_07_28 (18).JPG’ @ error/constitute.c/ReadImage/544.
        convert: no images defined `photo/2012/2012_07_28/@eaDir/2012_07_28 (18).JPG/SYNOPHOTO:THUMB_XL.jpg’ @ error/convert.c/ConvertImageCommand/3044.
        — SYNOPHOTO:THUMB_XL.jpg thumbnail created
        convert: unable to open image `THUMB_XL.jpg’: Datei oder Verzeichnis nicht gefunden @ error/blob.c/OpenBlob/2641.
        convert: no decode delegate for this image format `THUMB_XL.jpg’ @ error/constitute.c/ReadImage/544.
        convert: no images defined `photo/2012/2012_07_28/@eaDir/2012_07_28 (18).JPG/SYNOPHOTO:THUMB_L.jpg’ @ error/convert.c/ConvertImageCommand/3044.
        — SYNOPHOTO:THUMB_L.jpg thumbnail created
        convert: unable to open image `THUMB_L.jpg’: Datei oder Verzeichnis nicht gefunden @ error/blob.c/OpenBlob/2641.
        convert: no decode delegate for this image format `THUMB_L.jpg’ @ error/constitute.c/ReadImage/544.
        convert: no images defined `photo/2012/2012_07_28/@eaDir/2012_07_28 (18).JPG/SYNOPHOTO:THUMB_B.jpg’ @ error/convert.c/ConvertImageCommand/3044.
        — SYNOPHOTO:THUMB_B.jpg thumbnail created
        convert: unable to open image `THUMB_B.jpg’: Datei oder Verzeichnis nicht gefunden @ error/blob.c/OpenBlob/2641.
        convert: no decode delegate for this image format `THUMB_B.jpg’ @ error/constitute.c/ReadImage/544.
        convert: no images defined `photo/2012/2012_07_28/@eaDir/2012_07_28 (18).JPG/SYNOPHOTO:THUMB_M.jpg’ @ error/convert.c/ConvertImageCommand/3044.
        — SYNOPHOTO:THUMB_M.jpg thumbnail created
        convert: unable to open image `THUMB_M.jpg’: Datei oder Verzeichnis nicht gefunden @ error/blob.c/OpenBlob/2641.
        convert: no decode delegate for this image format `THUMB_M.jpg’ @ error/constitute.c/ReadImage/544.
        convert: no images defined `photo/2012/2012_07_28/@eaDir/2012_07_28 (18).JPG/SYNOPHOTO:THUMB_S.jpg’ @ error/convert.c/ConvertImageCommand/3044.
        — SYNOPHOTO:THUMB_S.jpg thumbnail created

  • Brian A in SD says:

    Since I have yet to install Photo Station, is it usable at all without thumbnails?

    cd /usr/syno/etc.defaults/rc.d
    S77synomkthumbd.sh stop
    S88synomkflvd.sh stop

    • phillips321 says:

      If you do not want to use photo station then simply drop the photo’s in web root and allow indexing in the .htaccess file.

      Then you can browse the images just like browsing them on a simple filesystem.

  • Brian A in SD says:

    Wow, this is stretching my computer capability.

    I have a fairly new Diskstation, and all of my photos in one directory (not the Synology default “photo” directory) already on a diskstation hard drive. I have yet to install photo station, due to the thumbnail issue.

    I do not have a Lunix machine – I have Windows 7, but I know how to SSH into the diskstation, and navigate around.

    A few questions:
    1) Do I install photo station BEFORE running this script, or after?
    2) In looking at the script from Phillips321, it looks like it will create “@eaDir” directories throughout my photo collection. I would prefer this didn’t happen. Is this required to use photo station?

    3) Where do I get tput from curses package?

    [quote]
    The script uses “tput”, which requires the curses package. You’ll need to install that if you don’t have it already (I did not).
    [/quote]

    4) If I want to use Lunix and the source code from Phillips321 “as is”, do I copy the script over to my DS, and run it by typing

    [quote]
    My photo folder on the NAS is mounted on my OS as /Volumes/photo. So i guess i’m supposed to run it as ./synoThumbs.sh /Volumes/photo
    [/quote]

    ./synoThumbs.sh ?

    5) If I want to run it in Windows,

    Get image magic for windows
    http://www.imagemagick.org/script/binary-releases.php?ImageMagick=hr1s0m9asaqveku82iovblh934#unix

    Get ffmpeg
    http://ffmpeg.org/

    Install cygwin and associated DLL
    http://www.cygwin.com/

    I then tried to follow Brian’s edit of your script

    [quote]
    At any rate, I just modified the script to generate “_” instead of “:”, and then ssh’ed in to the synology and ran a tiny script that renames all the files to have a “:”. *whew*, painful.
    [/quote]

    …but I could not see where to make the mod. ???? Is it in this section of the script

    [quote]
    XLname=”SYNOPHOTO:THUMB_XL.jpg” ; XLsize=”1280×1280″;
    Lname=”SYNOPHOTO:THUMB_L.jpg” ; Lsize=”800×800″;
    Bname=”SYNOPHOTO:THUMB_B.jpg” ; Bsize=”640×640″;
    Mname=”SYNOPHOTO:THUMB_M.jpg” ; Msize=”320×320″;
    Sname=”SYNOPHOTO:THUMB_S.jpg” ; Ssize=”160×160″;
    [/quote]

    changing it to SYNOPHOTO_THUMB_XL.jpg?

    Thanks for your help,
    Brian

    • phillips321 says:

      1) It doesnt matter when you install photo station, before/after….
      2) @eaDir are the folders created by the Diskstation that store the thumbnails, i had to copy what synology were doing
      3) tput should already be installed in most linux distributions
      4) The script should not be run on a DiskStation, that defeats the purpose of it. It should be run on a Desktop/Laptop in order to harness the power of the cpu.
      5) Sorry i offer no support for windows

  • Thanks so much for this piece of code!!

    I was able to convert ~5000 pictures using my i5 Quad Core cpu in about 30 minutes, my DS212 already was converting since 2 weeks for only 1000 images!

    Additionally I can confirm the script still works using the latest DSM, DSM 4.1 beta (2567).

    best greetings from Germany, Florian

  • Tobias says:

    THANK YOU! Wohoo!

  • Jeroen says:

    Thank you, thank you, thank you. Converting these 40 000+ pics would have taken ages

  • Manga says:

    I wanted to thank you for the script..
    I’m almost done with the thumbnailing…..
    I did try some extra “extensions” and it works perfectly with canon CRW or CR2 files… (you maight need to install ufraw)

  • Brian says:

    BTW, did you guys have the same issue with portrait images that I did? The imagemagick script doesn’t take orientation into account, so all my portrait images came out with perspective messed up…

    • Lucas says:

      No problems with portrait thumbnails for me…

    • phillips321 says:

      Most of my photo’s are taken with 400D and iphone and all good here.

    • Brian says:

      Hmm… I guess I’ll have to revisit this to see what the deal is… The images are fine before going into the Synology. It may have to do with the fact that I’ve rotated them before storing on the NAS (Using ACDSee). I’ll do some experiments and if I find anything note-worthy, will let you all know.

  • Lucas says:

    Thanks so much for this script, it worked fantastically well!

    For anyone else in the same boat, I had a few issues getting it to run properly: this script needs ImageMagick installed (it might be worth listing this as a requirement in the post above), and cannot be run over SMB/Samba (i used NFS and it worked fine).

    If you’re on Windows like me, a Linux virtual machine is probably the relatively easy solution, especially now that VMware Player is free and can create virtual machines.

    • phillips321 says:

      Just added dependency comments above, thanks.

      As it doesn’t work over SMB I suggest the best thing for people to do who haven’t got NFS set up is to run it against local photos and then transfer the completed directory to the DS using SMB.

  • Brian says:

    And…. no. I take it back. The “:” files, when viewed from an ssh shell on the synology, showed a garbled character where the “:” was supposed to be. Cygwin allows you to do something like “touch dog:cat”, and a file is created. If you open an explorer window, you’ll see what looks like a raised dot where the colon should be. Hurray for Windows! At any rate, I just modified the script to generate “_” instead of “:”, and then ssh’ed in to the synology and ran a tiny script that renames all the files to have a “:”. *whew*, painful.

  • Gonzague says:

    Hi,

    There is something I don’t understand, how to run the script ? I’m using Mac OS X and I have imagemagick and ffmpeg installed.

    My photo folder on the NAS is mounted on my OS as /Volumes/photo. So i guess i’m supposed to run it as ./synoThumbs.sh /Volumes/photo

    but i keep getting these errors

    1
    2
    3
    4
    mkdir: /Volumes/photo/2007/Corse/@eaDir: Invalid argument
    chmod: /Volumes/photo/2007/Corse/@eaDir/PICT0119.JPG: Invalid argument
    convert: unable to open image `/Volumes/photo/2007/Corse/@eaDir/PICT0119.JPG/SYNOPHOTO:THUMB_XL.jpg': Invalid argument @ error/blob.c/OpenBlob/2617.
       -- SYNOPHOTO:THUMB_XL.jpg thumbnail created

    When i do a ls -ali on my photo folders the @eaDir not present on the mounted volume but is when i connect through ssh to my nas.

    Is there something I’m missing ?

    • phillips321 says:

      Looks to be something to do with the way the mac handles directories named with @eaDir in them.

      When I get back home I’ll have a play with my mac and see if I can reproduce the error.

  • RainySmile says:

    Processing the thumbs on the poor little DS cpu is really cruel. It’s obviously not optimized for image processing and why should it be. So I was really amazed to see my desktops eight cores work through several GiB of img/vid in no time! Network and cpu utilization levels out quite well with gbit ethernet and only few vids, really nice.

    I Love this tool! Big thanks!

  • Dignan88 says:

    Hi. I am having a huge problem with the photo conversion after having updated to DSM4.0 It is reindexing all of my media, and has hung up on the photo conversion, running the CPU at full, and making access to the server incredibly slow.

    Can you advise a code noob how to run this on a mac, and have it convert files in the photo directory on my synology volume labeled “volume1″?

    Much appreciated!

    • phillips321 says:

      First of all this was designed for linux, not BSD or Cygwin (your mileage might vary).
      Make sure you have imagemagic installed in order to have the convert program available.
      Make sure you have ffmpeg installed in order to convert the videos.

      Rather than run against the root of /volume1 can you try running it first against a small directory within such as /volume1/photo/myfirstholiday/day1

      If it runs fine against that then it’s down to the find function taking ages to locate the picture/video files

  • Max says:

    Hallo Phillips321,

    after searching the web i found you project. that’s really interesting. I have just a little problem. I’m not a script expert and i would like to know if the script will run recursively into directory of directory. In other words i have a photo structure like this photo/year xxx/event name. Is there an option to do that?

    Thanks a lot in advance
    Speedymax

  • Thanks for the script!

    I had given up on using my DS1511+ with Photostation because of the thumbnail issue.
    I have 80,000+ vacation pictures that last time took 6 weeks to thumbnail; using your script it took a single day.

    I can’t understand how Synology has let this one slide for so long; unless it’s just not that popular a feature?

    Would love to see a GUI for this as well …

    • phillips321 says:

      Not sure if I could program a GUI for it but a TUI using dialog would be possible. I do have intentions to improve it in order to manage video thumbnails and conversions as well.

  • Paul Priest says:

    Turns ut i ws wrng, i’d been testing frm the cygwin side. windows and colons in filenames are a ad mix. Windows refuses to list the files, unless it’s encoded as this weird three-byte sequence (which may well be utf-8 although i’d need to check which codepoint it’s translating to. But then it’s stuffed in Synology land.
    The only solution i found was to batch rename to remove colons, generate the missing thumbs, and rename back afterwards.
    Another issue i ran into is i have a lot or Olympus RAW (.ORF) files, which the diskstation takes a lot of cpu to process, but which the cygwin ImageMagick seemingly barfs on, despite it being listed as a supported format without further plugins. It shouldn’t be a big deal to invoke ffmpeg to produce movie thumbs too, although clearly you’d want to find a way to copy only enough to produce the thumb and not the whole file to avoid network traffic. Or maybe just leave that to the built-in given they are hopefully less numerous…

    Still, for a slow network, copying the file across once, creating all missing thumbs and copying back has got to be the way to go.

  • Paul Priest says:

    Hi, thanks for this.
    I (unsurprisingly) ran into some issues doing this from Cygwin on Win7 with a Network drive. `convert“ was writing corrupt filenames (can’t handle the semi-colons it seems).

    I’ve made a few tweaks to change the algo to copy to a local drive if any of the thumbs are missing, process there and copy the thumbs back. That should speed it up, and has the nice side-effect of fixing my aforementioned issue.

    The main block now looks:

    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
    for i in `find ${1} \( -type f -a \( -iname "*.jpg" -o -iname "*.png" -o -iname "*.jpeg" \) ! -path "*@eaDir*" \)`
    do
      picName=`echo "${i}" |  awk -F\/ '{print $NF}'`
      picDir=`echo "${i}" | sed s/"${picName}"//g | sed s/.$//`
      echo "Searching Thumbs For $i"
      [[ !(-d "$picDir"/"@eaDir"/"$picName") ]] && (mkdir -p "$picDir""/@eaDir/""$picName"; chmod 775 "$picDir"/"@eaDir"/"$picName";)

      # If any sizes missing
      if [[ !((-f "$picDir"/"@eaDir"/"$picName"/"$XLname") ||\
              (-f "$picDir"/"@eaDir"/"$picName"/"$Lname") ||\
              (-f "$picDir"/"@eaDir"/"$picName"/"$Bname") ||\
              (-f "$picDir"/"@eaDir"/"$picName"/"$Mname") ||\
              (-f "$picDir"/"@eaDir"/"$picName"/"$Sname")) ]]; then
             
        # copy to $TEMP, use ImageMagick to generate missing thumbs, copy back
        $PREFIX cp "$picDir"/"$picName" "$TEMP/working"
        [[ !(-f "$picDir"/"@eaDir"/"$picName"/"$XLname") ]] && ($PREFIX convert -size $XLsize $TEMP/working -resize $XLsize -auto-orient -flatten $TEMP/workingXL; $PREFIX cp "$TEMP/workingXL" "$picDir"/"@eaDir"/"$picName"/"$XLname"; echo "   -- "$XLname" thumbnail created";)
        [[ !(-f "$picDir"/"@eaDir"/"$picName"/"$Lname") ]] && ($PREFIX convert -size $XLsize $TEMP/working -auto-orient -resize $Lsize $TEMP/workingL; $PREFIX cp "$TEMP/workingL" "$picDir"/"@eaDir"/"$picName"/"$Lname"; echo "   -- "$Lname" thumbnail created";)
        [[ !(-f "$picDir"/"@eaDir"/"$picName"/"$Bname") ]] && ($PREFIX convert -size $Lsize $TEMP/working -auto-orient -resize $Bsize $TEMP/workingB; $PREFIX cp "$TEMP/workingB" "$picDir"/"@eaDir"/"$picName"/"$Bname"; echo "   -- "$Bname" thumbnail created";)
        [[ !(-f "$picDir"/"@eaDir"/"$picName"/"$Mname") ]] && ($PREFIX convert -size $Bsize $TEMP/working -auto-orient -resize $Msize $TEMP/workingM; $PREFIX cp "$TEMP/workingM" "$picDir"/"@eaDir"/"$picName"/"$Mname"; echo "   -- "$Mname" thumbnail created";)
        [[ !(-f "$picDir"/"@eaDir"/"$picName"/"$Sname") ]] && ($PREFIX convert -size $Msize $TEMP/working -auto-orient -resize $Ssize $TEMP/workingS; $PREFIX cp "$TEMP/workingS" "$picDir"/"@eaDir"/"$picName"/"$Sname"; echo "   -- "$Sname" thumbnail created";)
         
        $PREFIX rm "$TEMP/working" "$TEMP/workingXL" "$TEMP/workingL" "$TEMP/workingB" "$TEMP/workingM" "$TEMP/workingS"
      fi
    done
    • phillips321 says:

      I’ll have a look at improving the code so that it can be used on both cygwin and *nix. Cheers for the pointers

    • Brian says:

      I was excited to see this cygwin modified script, but then quickly became disappointed when I tried to use it. The block posted here has been munged pretty badly (The backword single quote got converted into something funky, your double-ampersands got turned into HTML entities), and has at least one error. It says

      1
          [[ !(-f "$picDir"/"@eaDir"/"$picName"/"$Lname") ]] && ($PREFIX convert -size $XLsize $TEMP/working -auto-orient -resize $Lsize $TEMP/workingL; $PREFIX cp "$TEMP/workingL" "$picDir"/"@eaDir"/"$picName"/"$Lname"; echo "   — "$Lname" thumbnail created";)

      which is trying to convert a file called $TEMP/working. This should be $TEMP/working/”$picName”
      Also, what is “$PREFIX” which is all throughout? I removed those.

      To anyone trying to use this modification, it WILL work. Just fix the small errors, be sure to declare a “$TEMP” variable, and create the “working” directory in it. I also had to do a chmod a+rw on both the temp and the work dir, otherwise cygwin failed with a cryptic error message.

      The script uses “tput”, which requires the curses package. You’ll need to install that if you don’t have it already (I did not).

      Yay, hummin’ along now, way faster than my poor Synology was.
      Thanks so much for this idea, phillips321, and for the cygwin mod, Paul Priest!

      • @Brain, it would be nice if the modified Cygwin script was posted here ;-)

        • Brian says:

          Yes, I should have posted up my modified version. I’ve done a lot of other things to it since then as well. Since I’m not running it on Linux, but Windows, I can’t generate file names with “:” in them. So, I modified the script a bit for that (I think have a small script that runs on the NAS to rename the files appropriately).

          I’m in the middle of wedding plans now, but will try to get back to this at some point..

          Brian (“Brain” is a nice compliment though. hehe)

Leave a Reply