picaxe.picaxe module

work with the Flickr API to upload images, sort images, generate MD image reference links etc.

class picaxe.picaxe.picaxe(log, settings=False, pathToSettingsFile=False)[source]

work with the Flickr API to upload images, sort images, generate MD image reference links etc

Key Arguments:
  • log – logger
  • settings – the settings dictionary
  • pathToSettingsFile – path to the settings file
authenticate()[source]

setup a Flickr API key to access a Flickr user account so picaxe can work on private images

Return:
  • None

Usage:

To authenicate pixace against a Flickr account run the following (note this is interactive so a human needs to be present to respond to prompts!)

from picaxe import picaxe
flickrClient = picaxe(
    log=log,
    settings=settings
)
flickrClient.authenticate()
get_photo_metadata(url)[source]

get useful image metadata for the image found at a give Flickr share URL

Key Arguments:
  • url – the share URL for the flickr image (or just the unique photoid)
Return:
  • images – a dictionary of the various image sizes that can be accessed (key is the width in pixels and value is the direct image URL)
  • title – the title of the image as set by the user
  • desc – the description of the image as set by the user
  • photoId – the unique photoID of the image

Usage:

To get some associated metadata related to the image at a given Flcikr share URL run the get_photo_metadata method. Note the URL can be any of the various Flickr URL flavours.

from picaxe import picaxe
flickr = picaxe(
    log=log,
    settings=settings
)
images, title, desc, photoId = flickr.get_photo_metadata(
    url="https://www.flickr.com/photos/92344046@N06/30455210056")

images, title, desc, photoId= flickr.get_photo_metadata(
    url="https://www.flickr.com/gp/923440134@N06/0930a6")

images, title, desc, photoId = flickr.get_photo_metadata(
    url="http://flic.kr/p/NpdUV5")

images, title, desc, photoId = flickr.get_photo_metadata(
    url=30455210056)
list_album_titles()[source]

list all of the albums (photosets) in the Flickr account

Return:
  • albumList – the list of album names

Usage:

from picaxe import picaxe
flickr = picaxe(
    log=log,
    settings=settings
)
albumList = flickr.list_album_titles()

and, if you print the list of albums:

[u'Auto Upload', u'home movies', u'projects: thespacedoctor', u'notes: images and screengrabs']
md(url, width='original')[source]

generate a multimarkdown image link viewable anywhere (no sign-in needed for private photos)

Key Arguments:
  • url – the share URL for the flickr image (or just the unique photoid)
  • width – the pixel width of the fully resolved image. Default original. [75, 100, 150, 240, 320, 500, 640, 800, 1024, 1600, 2048]
Return:
  • md – the image reference link in multi-markdown syntax

Usage:

To return the markdown markup for an image at a given Flickr share URL:

from picaxe import picaxe
Flickr = picaxe(
    log=log,
    settings=settings
)
mdLink = Flickr.md(
    url="https://www.flickr.com/photos/92344916@N06/30455211086"
    width=1024
)
upload(imagePath, title=False, private=True, tags=False, description=False, imageType='photo', album=False, openInBrowser=False)[source]

upload

Key Arguments:
  • imagePath – path to the image to upload
  • title – title of the image. Default False to just use filename
  • private – is photo private?, Default True
  • tags – a comma separated string. Default False
  • description – the description for the image/photo. Default False
  • imageType – image type. Default photo [photo|screengrab|image]
  • album – add the photo to a specific album/photoset. If the album does not exist it will be created for you. Default False.
  • openInBrowser – view the photo in flickr webapp once uploaded Default: False
Return:
  • photoid – the unique flickr-assigned ID of the uploaded image

Usage:

To upload an image to flickr from your local file-system, use the following:

from picaxe import picaxe
flickr = picaxe(
    log=log,
    settings=settings
)
photoid = flickr.upload(
    imagePath="/path/to/image.png",
    title="my lovely image",
    private=False,
    tags="lovely, icon",
    description="this is a test image",
    imageType="image",
    album="my icons",
    openInBrowser=True
)
print photoid

This will upload an image to the “my icons” album (creating the album if it doens’t exist yet) and open the image in the flickr web-app whenever upload is complete. Note title, description, tags and album are optional.