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](http://www.flickr.com/help/forum/22354/) about the issue, with one suggested solution being to manually set the ‘posted’ date of every photo to the ‘taken’ date. A [utility](http://www.h4ppy.com/h4ppier-photos.php) 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](http://sortmyphotostream.michael.tyson.id.au) 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](http://sortmyphotostream.michael.tyson.id.au), or get access to the [SortMyFlickrPhotostream source](https://github.com/michaeltyson/SortMyFlickrPhotostream).
Leave a comment below if it’s useful to you.
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.
Great idea and we included it in our Flickr-related blog in German: http://flickrbuch.wordpress.com/2009/06/09/flickr-fotostream-automatisch-nach-aufnahmedatum-sortieren/
Looks great… downloaded the source and played around with it. I too was getting the memory error. Tracked it down to the limitation on flickr.photos.search 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 (http://www.flickr.com/services/api/explore/) 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…..
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….
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?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 config.inc.php, I added ini_set(‘memory_limit’, 128 * 1024 * 1024);)
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 =)
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: http://www.flickr.com/photos/sarahandadam/ Please let me know if there is anything else I can do to make the tool work for me! Thanks!
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!
I got an error trying to restore my back up file. Is there anything I can do?
same problem here. I got all my upload dates changed to april 2009.
thanks
GREAT!! THANKS A LOT!! (In Japanese, 2Bytes OK)
Tested and works for me! Many thanks! Do you mind that I intro this tool on a Chinese forum from Taiwan? link: http://www.mobile01.com/topicdetail.php?f=164&t=1266956&p=1#17714294#17714294
Not at all, Su, go ahead – glad it works for you!
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: http://flickr.com/gp/suweijack/0PRj7z
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: http://www.flickr.com/photos/gtasioulis/archives/
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?
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?
It should be useful change the order to a custom one sorting the thumbnails to the desired order…
Thanks Fabio – What kind of ordering do you think would be helpful?
Hi Michael, any special kind of ordering, but a ui like this: http://davidwalsh.name/dw-content/sort-save.php
Saving only changed photos will speed-up the saving process especially when the are many photos…
Thank you!! This is awesome!! Saved me a lot of time too! You rock! :)
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.
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)?
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?
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
Joined Flickr in March, and I’ve been posting photo’s ever since.
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
Great App – did exactly what it said on the tin and saved me lots of time !
^^^^What he said! Thanks!
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..
Thank you! This is exactly what I was looking for!
Cheers, Gerard
Yep – all good, tried another which failed. yours worked. Cheers!
Thank you, thank you, thank you. This makes up for Flickr numerous inadequacies.
Worked great! Thanks!
Thanks a ton, saved me a lot of time!
Thank you so much!! Works great.
Thank you! (Flickr, why do you not support this?)
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!
Ah, looks like the DNS record broke. Should be better in about 24 hours once the caches are reset, I think.
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.
Great – cheers for the heads-up
Hmm.. getting php errors and nothing else. Something on the hosting side broke?
Okay, all fixed. Just some dumb deprecation warnings messing things up.
Is there a confirmation once its complete? It’s just sitting at the sortmyphotostream banner.
Yup, there should be. It might’ve timed out, which can happen with a huge number of photos. Try it again.
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.