Sort your Flickr photostream

Flickr has a limitation that your photostream is ordered by the date you uploaded your photos, and this order can’t be changed. If you’ve done a big import of photos – say, from iPhoto – then they could show up in your photostream in any order.

There’s been some talk about the issue, with one suggested solution being to manually set the ‘posted’ date of every photo to the ‘taken’ date. A utility exists to do this, but it has some major limitations, including a difficult user interface and limitation that causes the process to fail if you have any photos that were taken before the date you set up your Flickr account.

So, I’ve made a utility specifically for sorting a Flickr photostream. It should be fairly user friendly, and provides the ability to backup and restore your photo metadata, in case you ever want to revert.

Check it out here: SortMyPhotostream, or get access to the SortMyFlickrPhotostream source.


Leave a comment below if it’s useful to you.

, . Bookmark the permalink. Both comments and trackbacks are currently closed.


  1. Pepijn
    Posted June 9, 2009 at 1:38 am | Permalink

    Hi Michael, Great idea! However don't seem to get it working though… :-( I'm keep getting this error message: Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 35 bytes) in /home/tysonid/public_html/sortmyphotostream/apply.php on line 84 Any idea what this means? Thanks, Pepijn.

  2. Markus
    Posted June 10, 2009 at 5:52 am | Permalink

    Great idea and we included it in our Flickr-related blog in German:

  3. Ken
    Posted June 10, 2009 at 1:42 pm | Permalink

    Looks great… downloaded the source and played around with it. I too was getting the memory error. Tracked it down to the limitation on api call of a max of 500 photos. I edited the call to limit based on tag – if I got a response that had more than 500 items in it, I'd run out of memory (no matter my PHP server settings). If I added the 'page' attribute and dropped the per_page to 499 it would work – but had to do it for each page. The following would work: 'page' => 2, 'per_page' => 499, but this did not: 'page' => 2, 'per_page' => 500, Using the API explorer ( for that method it worked to get more than 500 back. I'm guessing it has something to do with the line: while ( count($result['photo']) == 500 ); Haven't had time to debug that yet. Great tool though and it's been fun "getting it working"!! Thanks for the code…..

  4. Ken
    Posted June 10, 2009 at 3:52 pm | Permalink

    Some other minor changes

    Changed the apply.php to: <code>$date = $photo['datetaken'];

    $unix_date = strtotime($date);</code>

    Not sure why it comes back as datetaken when you 'pop' it as date_taken, but it does. Then need to convert the date to unix because the setDates function requires Unix timestamp. Still haven't worked out the > 500 issues, but doing it in chunks with min_taken_date and max_taken_date in conjunction with page tags. hope this is helpful….

  5. Posted June 10, 2009 at 6:49 pm | Permalink

    Hi guys!
    My bad about the memory issue – that should be fixed now (I'm processing 500 photos at a time now, which makes much more sense than loading them all, then processing)

    Ken: That's interesting, why the addition of strtotime? Was the API returning dates in string format, not timestamps any more?

  6. Ken
    Posted June 10, 2009 at 10:02 pm | Permalink

    For some reason it was returning a string date – but didn’t know this until I trapped the error… Not sure if it’s new or my implementation of it. Also, forgot that I added the API_TOKEN to star ($flickr->setToken(API_TOKEN);) – for some reason it wasn’t allowing my auth through Flickr….

    What was it that you changed for the memory issue? I upped my php settings to 128M and still ran out of memory… (in the, I added ini_set(‘memory_limit’, 128 * 1024 * 1024);)

    • Posted June 16, 2009 at 7:31 pm | Permalink

      I was being very silly and loaded a list of all photos first, then processed them afterwards. Now, instead, I just do 500 at a time =)

  7. Sarah
    Posted July 6, 2009 at 5:13 am | Permalink

    I tried your tool, but for some reason it set the upload date for every photo to January 22, 2006. There is clearly a date taken for all of the pictures (or 95% of them) that is more recent than that. Not sure what happened, not a huge deal, since it didn’t actually change the order they are in (still in the same order as before, just with a new date uploaded that is not what it used to be, and not the same as the date taken), but I wanted to let you know. My photostream is at: Please let me know if there is anything else I can do to make the tool work for me! Thanks!

    • Posted July 6, 2009 at 11:03 am | Permalink

      Hello, There’s a chance that I need to do some more careful date formatting when setting the posted date – Try now and let me know if it works!

  8. Sim1
    Posted July 20, 2009 at 3:48 pm | Permalink

    I got an error trying to restore my back up file. Is there anything I can do?

  9. Posted July 27, 2009 at 3:11 am | Permalink

    same problem here. I got all my upload dates changed to april 2009.


  10. hiroam
    Posted January 8, 2010 at 7:51 am | Permalink

    GREAT!! THANKS A LOT!! (In Japanese, 2Bytes OK)

  11. Su Wei-Chieh
    Posted February 24, 2010 at 2:53 am | Permalink

    Tested and works for me! Many thanks! Do you mind that I intro this tool on a Chinese forum from Taiwan? link:

    • Posted February 24, 2010 at 2:34 pm | Permalink

      Not at all, Su, go ahead – glad it works for you!

      • Su Wei-Chieh
        Posted February 25, 2010 at 5:40 am | Permalink

        Hi Michael, Thanks! There is one minor thing: I did not check further about the changed date posted after the process yesterday. Today I found the modified date posted are not as same as the date taken – they were changed to some time around 10/05/2009, while the date taken is 02/14/2010. Anyway the photostream sorted as I want, just let you know maybe you could do some further checking. See below two figures about what I am saying:

  12. Posted April 3, 2010 at 8:17 pm | Permalink

    Hello Michael, thanks for the tool. Although I just tried it out and it changed the “date picture uploaded” to Sep 21, 2009 for all my photos. Also I made a backup before running the tool, but the restore script produces an “not enough arguments” error, so I can’t restore the metadata either.

    The date taken wasn’t changed (which is good) as you can see in the archives page of my flickr account:

    Any idea of how I can fix that? Do you think I should re-run the script again (since the “date taken” metadata is fine) or could you give me a solution on how to make the restore function work so I can make everything look back to how it was before running the script?

    • Posted April 4, 2010 at 4:02 pm | Permalink

      Hi George,

      Sorry to hear it’s not working properly for you; I’m really not sure what it could be, particularly given that it works properly for others – I’m yet to figure out what the factor is that breaks it for some people.

      Do you get any more specific errors when you try to restore?

  13. Posted May 15, 2010 at 1:12 pm | Permalink

    It should be useful change the order to a custom one sorting the thumbnails to the desired order…

    • Posted May 29, 2010 at 2:43 pm | Permalink

      Thanks Fabio – What kind of ordering do you think would be helpful?

  14. Posted June 6, 2010 at 12:25 pm | Permalink

    Hi Michael, any special kind of ordering, but a ui like this:

    Saving only changed photos will speed-up the saving process especially when the are many photos…

  15. Posted July 10, 2010 at 2:54 am | Permalink

    Thank you!! This is awesome!! Saved me a lot of time too! You rock! :)

  16. Marc
    Posted July 23, 2010 at 7:51 pm | Permalink

    Hey, as always this has been a time saver. I was just wondering if anyone came up with any solutions on the upload date. Mine always sets every photo to Feb. 2, 2010. Other than that it orders correctly.

    • Posted July 23, 2010 at 11:05 pm | Permalink

      That’s, as always, quite bizarre. You don’t, perchance, either have a photostream full of photos taken on that date, or possibly all taken before the date you subscribed to Flickr (if it’s that date)?

      • SK
        Posted August 1, 2010 at 8:37 am | Permalink

        Michael, the ordering is now correct but the Date Taken says March 2010 for all of my photo’s…..this seems to be a problem most people are having. I downloaded a backup of it before i ran the test….though how can i revert it back? Also, is there a way to individually change the ordering, rather than batch?

        • Posted August 1, 2010 at 12:17 pm | Permalink

          Yes, I’ve tried to debug that one but haven’t found anyone having the problem willing to stick around to talk about it ;-) When did you join Flickr? Do you have any photos taken after that date?

          You can restore by going to the site and clicking ‘restore’

          No, there’s no configuration with the app

          • SK
            Posted August 1, 2010 at 5:01 pm | Permalink

            Joined Flickr in March, and I’ve been posting photo’s ever since.

  17. boaz mottes
    Posted January 12, 2011 at 10:02 pm | Permalink

    hi i tray your “sort your flickr photosream” and it work great. can you make 1 that put the photos in the order thay are taken? now the last photo that i taken is first in the photostream. i want the first 1 i take to be the first.

    thank you boaz

  18. Posted January 29, 2011 at 1:14 pm | Permalink

    Great App – did exactly what it said on the tin and saved me lots of time !

    • Ryan
      Posted February 23, 2011 at 8:23 am | Permalink

      ^^^^What he said! Thanks!

  19. Sam
    Posted April 29, 2011 at 10:02 pm | Permalink

    Is there a way to get your SETs to sort by date? I’ve used another app to sort alphabetically, so that I could organize/edit better; but am now not able to get it to go back to sorting the actual SETs by date uploaded..

  20. Posted April 30, 2011 at 3:22 am | Permalink

    Thank you! This is exactly what I was looking for!

    Cheers, Gerard

  21. Posted May 12, 2011 at 4:04 pm | Permalink

    Yep – all good, tried another which failed. yours worked. Cheers!

  22. Chris Morris
    Posted August 15, 2011 at 1:30 pm | Permalink

    Thank you, thank you, thank you. This makes up for Flickr numerous inadequacies.

  23. Jon Gilbert
    Posted August 22, 2011 at 12:32 am | Permalink

    Worked great! Thanks!

  24. bbrous
    Posted November 1, 2011 at 1:36 am | Permalink

    Thanks a ton, saved me a lot of time!

  25. Oli
    Posted January 28, 2012 at 3:56 am | Permalink

    Thank you so much!! Works great.

  26. RAM
    Posted August 27, 2012 at 10:17 pm | Permalink

    Thank you! (Flickr, why do you not support this?)

  27. Pete
    Posted May 9, 2013 at 9:46 pm | Permalink

    Hi – I used this great tool a couple of years back but noticed the URL doesn’t work any more.

    Did Flickr change something in the API that meant you had to take the link down or is it going to return someday? It was the best I’d seen at the time, mainly because it had a nice workaround for photos taken before my Flickr account had been created. Thanks!

    • Posted May 10, 2013 at 2:58 am | Permalink

      Ah, looks like the DNS record broke. Should be better in about 24 hours once the caches are reset, I think.

      • Pete
        Posted May 10, 2013 at 9:03 am | Permalink

        Thanks for the quick resolution – it’s back in action for me.

        Whilst I was Googling for this I noticed a few others had been wondering where it had gone, so you’ve definitely made a few of us very happy!

        Thanks again.

  28. Casper
    Posted May 23, 2013 at 7:05 am | Permalink

    Hmm.. getting php errors and nothing else. Something on the hosting side broke?

    • Posted May 23, 2013 at 7:35 am | Permalink

      Okay, all fixed. Just some dumb deprecation warnings messing things up.

  29. Posted May 29, 2013 at 1:26 am | Permalink

    Is there a confirmation once its complete? It’s just sitting at the sortmyphotostream banner.

    • Posted May 29, 2013 at 2:45 am | Permalink

      Yup, there should be. It might’ve timed out, which can happen with a huge number of photos. Try it again.

  30. M Zimmermann
    Posted June 6, 2013 at 10:10 am | Permalink

    Hello, while trying to sort my photos an error occured that says i should contact you because of a log file on the server. Thanks Martin.