So, my usual workflow for posting photos here is:
1) Upload to Flickr as a set
2) Go through each photo and
2.1) Copy the image url
2.2) Paste into a thread as [eimg]http://flickr.com/whatever/123.jpg[/eimg]
3) Preview the page, and go resize each image using the [img=100,200][/img]syntax
4) Post
So, being the lazy bum I am, I threw together a little python script last night to do this for me. It's a really rough, prototypical thing, and has 0 error handling, but it works. You give it a username, a flickr set name, a maximum width, and tell it whether you want your [eimg]s wrapped in [url]s, and it gives you back a list like:
[url=http://farm5.static.flickr.com/4016/4715644312_d89d761d28_o.jpg][img=600,399]http://far m5.static.flickr.com/4016/4715644312_4c2f54aaf0_b.jpg[/eimg][/url]
[url=http://farm5.static.flickr .com/4050/4715645728_65dd74afd7_o.jpg][img=600,399]http://farm5.static.flickr.com/4050/4715645728_81f 98aeeaf_b.jpg[/img][/url]
[url=http://farm5.static.flickr.com/4070/4715667292_78133ac8be_o.jpg][im g=600,787]http://farm5.static.flickr.com/4070/4715667292_f3ec582760_b.jpg[/img][/url]
Anyway, all you need is Python and
this guy's python flickr kit. I'm planning to eventually clean it up and give it a web interface at some point (right now the UI is just editing the variables in the script), but I figured people here might find it useful as it is if they're able to intall a python module and run a python program. Script:
import flickrapi userName="macman5151" setName="Summer Camp" targetSize="Large" maxWidth = 600; makeLinks = False; def formatToPrint(source,url,width,height): newHeight=height newWidth=width if(maxWidth<width): newHeight = int(height * ((1.0*maxWidth)/(width))) newWidth = int(maxWidth) img = "[img="+str(newWidth)+","+str(newHeight)+"]"+source+"[/img]" result = "[url="+url+"]"+img+"[/url]" return result if makeLinks else img api_key = '7c0d60047e1d56575439268441bfcb26' flickr = flickrapi.FlickrAPI(api_key) userTree = flickr.people_findByUsername(username=userName) userId = userTree.getchildren()[0].attrib['nsid'] setTree = flickr.photosets_getList(user_id=userId) photosets = setTree.getchildren()[0].getchildren() setId = -1; for photoset in photosets: title = photoset.find('title').text if(setName==title): setId = photoset.attrib['id'] break photoset = flickr.photosets_getPhotos(photoset_id=setId).getchildren()[0] height=-1 width=-1 url = '' for photo in photoset.getchildren(): id = photo.attrib['id'] sizes = flickr.photos_getSizes(photo_id=id).getchildren()[0] for size in sizes: if(size.attrib['label']==targetSize): width = int(size.attrib['width']) height = int(size.attrib['height']) source = size.attrib['source'] if(size.attrib['label']=='Original'): url = size.attrib['source'] print formatToPrint(source,url,width,height)
|