Server version‎ > ‎Documents‎ > ‎

    API Reference

    List of functions available through XML-RPC and SOAP.

    Also refer to API usage for some best practices.

    Functions
    array
    queryImgID(dbIdidnumres=12sketch=0fast=False)
    Return the most similar images to the supplied one.
    array
    queryImgBlob(dbIddatanumres=12sketch=0fast=False)
    Return the most similar images to the supplied one.
    array
    queryImgPath(dbIdpathnumres=12sketch=0fast=False)
    Return the most similar images to the supplied one.
    number
    addImgBlob(dbIdiddata)
    Add image to database space.
    number
    addImg(dbIdidfilenamefileIsUrl=False)
    Add image to database space.
    number
    saveDb(dbId)
    Save the supplied database space if the it has already been saved with a filename (previous call to saveDbAs).
    number
    saveDbAs(dbIdfilename)
    Save the supplied database space if the it has already been saved with a filename (subsequent save calls can be made to saveDb).
    number
    loadDb(dbIdfilename)
    Load the supplied single-database-space-dump into a database space of given id.
    number
    removeImg(dbIdid)
    Remove image from database space.
    number
    resetDb(dbId)
    Removes all images from a database space, frees memory, reset statistics.
    number
    createDb(dbId)
    Create new db space.
    number
    shutdownServer()
    Request a shutdown of this server instance.
    number
    getDbImgCount(dbId)
    Return count of indexed images on database space.
    boolean
    isImgOnDb(dbIdid)
    Return whether image id exists on database space.
    array
    getImgDimensions(dbIdid)
    Returns image original dimensions when indexed into database.
    number
    calcImgAvglDiff(dbIdid1id2)
    Return average luminance (over three color channels) difference ratio
    number
    calcImgDiff(dbIdid1id2)
    Return image similarity difference ratio
    array of double
    getImgAvgl(dbIdid)
    Return image average color levels on the three color channels (YIQ color system)
    array
    getDbList()
    Return list defined database spaces.
    array
    getDbImgIdList(dbId)
    Return list of image ids on database space.
    map
    getDbDetailedList()
    Return details for all database spaces.
    number
    saveAllDbsAs(path)
    Persist all existing database spaces.
    boolean
    addKeywordImg(dbIdimgIdhash)
    Adds a keyword to an image.
    array
    getAllImgsByKeywords(dbIdnumreskwJoinTypekeywords)
    Return all images with the given keywords
    array
    queryImgIDFastKeywords(dbIdimgIdnumreskwJoinTypekeywords)
    Fast query (only considers average color) for similar images considering keywords
    array
    queryImgIDKeywords(dbIdimgIdnumreskwJoinTypekeywords)
    Query for similar images considering keywords.
    array
    mostPopularKeywords(dbIdimgsexcludedKwdscountmode)
    Returns the most frequent keywords associated with a given set of images
    array
    getKeywordsImg(dbIdimgId)
    Returns all keywords currently associated with an image.
    boolean
    removeAllKeywordImg(dbIdimgId)
    Remove all keyword associations this image has.
    boolean
    removeKeywordImg(dbIdimgIdhash)
    Remove the association of a keyword to an image
    boolean
    addKeywordsImg(dbIdimgIdhashes)
    Associate keywords to image
    number
    addDir(dbIdpathrecurse)
    Visits a directory recursively and add supported images into database space.
    number
    loadAllDbsAs(path)
    Loads from disk all previously persisted database spaces.
    number
    saveAllDbs()
    Persist all existing database spaces on the data file defined at the config file settings.py
    number
    loadAllDbs()
    Loads from disk all previously persisted database spaces on the data file defined at the config file settings.py
    boolean
    removeDb(dbid)
    Remove a database.
    map
    getGlobalServerStats()
    Return the most similar images to the supplied one.
    boolean
    isValidDb(dbId)
    Return whether database space id has already been defined
    string
    getIskLog(window=30)
    Returns the last lines of text in the iskdaemon instance log
    Function Details

    queryImgID(dbIdidnumres=12sketch=0fast=False)

     

    Return the most similar images to the supplied one. The supplied image must be already indexed, and is referenced by its ID.

    Parameters:
    • dbId (number) - Database space id.
    • id (number) - Target image id.
    • numres (number) - Number of results to return. The target image is on the result list.
    • sketch (number) - 0 for photographs, 1 for hand-sketched images or low-resolution vector images.
    • fast (boolean) - if true, only the average color for each image is considered. Image geometry/features are ignored. Search is faster this way.
    Returns: array
    array of arrays: [[image id 1, score],[image id 2, score],[image id 3, score], ...] (id is Integer, score is Double)

    Since: 0.7

    Change Log: 0.9.3: added parameter 'sketch'

    queryImgBlob(dbIddatanumres=12sketch=0fast=False)

     

    Return the most similar images to the supplied one. The target image is specified by its raw binary file data. Most common formats are supported.

    Parameters:
    • dbId (number) - Database space id.
    • data (binary data) - Target image file binary data.
    • numres (number) - Number of results to return. The target image is on the result list.
    • sketch (number) - 0 for photographs, 1 for hand-sketched images or low-resolution vector images.
    • fast (boolean) - if true, only the average color for each image is considered. Image geometry/features are ignored. Search is faster this way.
    Returns: array
    array of arrays: [[image id 1, score],[image id 2, score],[image id 3, score], ...] (id is Integer, score is Double)

    Since: 0.9.3

    queryImgPath(dbIdpathnumres=12sketch=0fast=False)

     

    Return the most similar images to the supplied one. The target image is specified using it's full path on the server filesystem.

    Parameters:
    • dbId (number) - Database space id.
    • path (string) - Target image pth on the server disk.
    • numres (number) - Number of results to return. The target image is on the result list.
    • sketch (number) - 0 for photographs, 1 for hand-sketched images or low-resolution vector images.
    • fast (boolean) - if true, only the average color for each image is considered. Image geometry/features are ignored. Search is faster this way.
    Returns: array
    array of arrays: [[image id 1, score],[image id 2, score],[image id 3, score], ...] (id is Integer, score is Double)

    Since: 0.9.3

    addImgBlob(dbIdiddata)

     

    Add image to database space. Image data is passed directly. It is then processed and indexed.

    Parameters:
    • dbId (number) - Database space id.
    • id (number) - Target image id. The image located on filename will be indexed and from now on should be refered to isk-daemon as this supplied id.
    • data (binary) - Image binary data
    Returns: number
    1 in case of success.

    Since: 0.9.3

    addImg(dbIdidfilenamefileIsUrl=False)

     

    Add image to database space. Image file is read, processed and indexed. After this indexing is done, image can be removed from file system.

    Parameters:
    • dbId (number) - Database space id.
    • id (number) - Target image id. The image located on filename will be indexed and from now on should be refered to isk-daemon as this supplied id.
    • filename (string) - Physical full file path for the image to be indexed. Should be in one of the supported formats ('jpeg', 'jpg', 'gif', 'png', 'rgb', 'pbm', 'pgm', 'ppm', 'tiff', 'tif', 'rast', 'xbm', 'bmp'). For better results image should have dimension of at least 128x128. Thumbnails are ok. Bigger images will be scaled down to 128x128.
    • fileIsUrl (boolean) - if true, filename is interpreted as an HTTP url and the remote image it points to downloaded and saved to a temporary location (same directory where database file is) before being added to database.
    Returns: number
    1 in case of success.

    Since: 0.7

    saveDb(dbId)

     

    Save the supplied database space if the it has already been saved with a filename (previous call to saveDbAs). NOTE: This operation should be used for exporting single database spaces. For regular server instance database persistance, use saveAllDbs and loadAllDbs.

    Parameters:
    • dbId (number) - Database space id.
    Returns: number
    1 in case of success.

    Since: 0.7

    saveDbAs(dbIdfilename)

     

    Save the supplied database space if the it has already been saved with a filename (subsequent save calls can be made to saveDb).

    Parameters:
    • dbId (number) - Database space id.
    • filename (string) - Target filesystem full path of the file where data should be stored at. NOTE: This data file contains a single database space and should be used for import/export purposes only. Do not try to load it with a call to loadAllDbs.
    Returns: number
    1 in case of success.

    Since: 0.7

    loadDb(dbIdfilename)

     

    Load the supplied single-database-space-dump into a database space of given id. An existing database space with the given id will be completely replaced.

    Parameters:
    • dbId (number) - Database space id.
    • filename (string) - Target filesystem full path of the file where data is stored at. NOTE: This data file contains a single database space and should be used for import/export purposes only. Do not try to load it with a call to loadAllDbs and vice versa.
    Returns: number
    dbId in case of success.

    Since: 0.7

    removeImg(dbIdid)

     

    Remove image from database space.

    Parameters:
    • dbId (number) - Database space id.
    • id (number) - Target image id.
    Returns: number
    1 in case of success.

    Since: 0.7

    resetDb(dbId)

     

    Removes all images from a database space, frees memory, reset statistics.

    Parameters:
    • dbId (number) - Database space id.
    Returns: number
    1 in case of success.

    Since: 0.7

    createDb(dbId)

     

    Create new db space. Overwrite database space statistics if one with supplied id already exists.

    Parameters:
    • dbId (number) - Database space id.
    Returns: number
    dbId in case of success

    Since: 0.7

    shutdownServer()

     

    Request a shutdown of this server instance.

    Returns: number
    always 1

    Since: 0.7

    getDbImgCount(dbId)

     

    Return count of indexed images on database space.

    Parameters:
    • dbId (number) - Database space id.
    Returns: number
    image count

    Since: 0.7

    isImgOnDb(dbIdid)

     

    Return whether image id exists on database space.

    Parameters:
    • dbId (number) - Database space id.
    • id (number) - Target image id.
    Returns: boolean
    true if image id exists

    Since: 0.7

    getImgDimensions(dbIdid)

     

    Returns image original dimensions when indexed into database.

    Parameters:
    • dbId (number) - Database space id.
    • id (number) - Target image id.
    Returns: array
    array in the form [width, height]

    Since: 0.7

    calcImgAvglDiff(dbIdid1id2)

     

    Return average luminance (over three color channels) difference ratio

    Parameters:
    • dbId (number) - Database space id.
    • id1 (number) - Target image 1 id.
    • id2 (number) - Target image 2 id.
    Returns: number
    float representing difference. The smaller, the most similar.

    Since: 0.7

    calcImgDiff(dbIdid1id2)

     

    Return image similarity difference ratio

    Parameters:
    • dbId (number) - Database space id.
    • id1 (number) - Target image 1 id.
    • id2 (number) - Target image 2 id.
    Returns: number
    float representing difference. The smaller, the most similar.

    Since: 0.7

    getImgAvgl(dbIdid)

     

    Return image average color levels on the three color channels (YIQ color system)

    Parameters:
    • dbId (number) - Database space id.
    • id (number) - Target image id.
    Returns: array of double
    values for YIQ color channels

    Since: 0.7

    getDbList()

     

    Return list defined database spaces.

    Returns: array
    array of db space ids

    Since: 0.7

    getDbImgIdList(dbId)

     

    Return list of image ids on database space.

    Parameters:
    • dbId (number) - Database space id.
    Returns: array
    array of image ids

    Since: 0.7

    getDbDetailedList()

     

    Return details for all database spaces.

    Returns: map
    map key is database space id (as an integer), associated value is array with [getImgCount, queryCount, lastQueryPerMin, queryMinCount, queryMinCur, lastAddPerMin, addMinCount, addMinCur, addCount, addSinceLastSave, lastId, lastSaveTime, fileName ]

    Since: 0.7

    saveAllDbsAs(path)

     

    Persist all existing database spaces.

    Parameters:
    • path (string) - Target filesystem full path of the file where data is stored at.
    Returns: number
    total db spaces written

    Since: 0.7

    addKeywordImg(dbIdimgIdhash)

     

    Adds a keyword to an image.

    Parameters:
    • dbId (number) - Database space id.
    • imgId (number) - Target image id.
    • hash (number) - Keyword id.
    Returns: boolean
    true if operation was succesful

    Since: 0.7

    getAllImgsByKeywords(dbIdnumreskwJoinTypekeywords)

     

    Return all images with the given keywords

    Parameters:
    • dbId (number) - Database space id.
    • kwJoinType (number) - Logical operator for target keywords: 1 for AND, 0 for OR
    • keywords (string) - comma separated list of keyword ids. An empty string will return random images.
    Returns: array
    array of image ids

    Since: 0.7

    queryImgIDFastKeywords(dbIdimgIdnumreskwJoinTypekeywords)

     

    Fast query (only considers average color) for similar images considering keywords

    Parameters:
    • dbId (number) - Database space id.
    • kwJoinType (number) - logical operator for keywords: 1 for AND, 0 for OR
    • keywords (string) - comma separated list of keyword ids.
    • imgId (number @param imgId Target image id. If '0', random images containing the target keywords will be returned.)
    • numres (number @param numres Number of results desired)
    Returns: array
    array of arrays: [[image id 1, score],[image id 2, score],[image id 3, score], ...] (id is Integer, score is Double)

    Since: 0.7

    queryImgIDKeywords(dbIdimgIdnumreskwJoinTypekeywords)

     

    Query for similar images considering keywords. The input keywords are used for narrowing the search space.

    Parameters:
    • dbId (number) - Database space id.
    • imgId (number) - Target image id. If '0', random images containing the target keywords will be returned.
    • numres (number) - Number of results desired
    • kwJoinType (number) - logical operator for keywords: 1 for AND, 0 for OR
    • keywords (string) - comma separated list of keyword ids.
    Returns: array
    array of arrays: [[image id 1, score],[image id 2, score],[image id 3, score], ...] (id is Integer, score is Double)

    Since: 0.7

    mostPopularKeywords(dbIdimgsexcludedKwdscountmode)

     

    Returns the most frequent keywords associated with a given set of images

    Parameters:
    • imgs (string) - Comma separated list of target image ids
    • excludedKwds (string) - Comma separated list of keywords ids to be excluded from the frequency count
    • mode (number) - ignored, will be used on future versions.
    • dbId (number @param dbId Database space id.)
    • count (number @param count Number of keyword results desired)
    Returns: array
    array of keyword ids and frequencies: [kwd1_id, kwd1_freq, kwd2_id, kwd2_freq, ...]

    Since: 0.7

    getKeywordsImg(dbIdimgId)

     

    Returns all keywords currently associated with an image.

    Parameters:
    • dbId (number) - Database space id.
    • imgId (number) - Target image id.
    Returns: array
    array of keyword ids

    Since: 0.7

    removeAllKeywordImg(dbIdimgId)

     

    Remove all keyword associations this image has.

    Known issue: keyword based queries will continue to consider the image to be associated to this keyword until the database is saved and restored.

    Parameters:
    • dbId (number) - Database space id.
    • imgId (number) - Target image id.
    Returns: boolean
    true if operation succeeded

    Since: 0.7

    removeKeywordImg(dbIdimgIdhash)

     

    Remove the association of a keyword to an image

    Known issue: keyword based queries will continue to consider the image to be associated to this keyword until the database is saved and restored.

    Parameters:
    • dbId (number) - Database space id.
    • imgId (number) - Target image id.
    • hash (number) - Keyword id.
    Returns: boolean
    true if operation succeeded

    Since: 0.7

    addKeywordsImg(dbIdimgIdhashes)

     

    Associate keywords to image

    Parameters:
    • dbId (number) - Database space id.
    • imgId (number) - Target image id.
    • hashes (list of number) - Keyword hashes to associate
    Returns: boolean
    true if image id exists

    Since: 0.7

    addDir(dbIdpathrecurse)

     

    Visits a directory recursively and add supported images into database space.

    Parameters:
    • dbId (number) - Database space id.
    • path (string) - Target filesystem full path of the initial dir.
    • recurse (number) - 1 if should visit recursively
    Returns: number
    count of images succesfully added

    Since: 0.7

    loadAllDbsAs(path)

     

    Loads from disk all previously persisted database spaces. (File resulting from a previous call to saveAllDbs).

    Parameters:
    • path (string) - Target filesystem full path of the file where data is stored at.
    Returns: number
    total db spaces read

    Since: 0.7

    saveAllDbs()

     

    Persist all existing database spaces on the data file defined at the config file settings.py

    Returns: number
    count of persisted db spaces

    Since: 0.7

    loadAllDbs()

     

    Loads from disk all previously persisted database spaces on the data file defined at the config file settings.py

    Returns: number
    count of persisted db spaces

    Since: 0.7

    removeDb(dbid)

     

    Remove a database. All images associated with it are also removed.

    Returns: boolean
    true if succesful

    Since: 0.7

    getGlobalServerStats()

     

    Return the most similar images to the supplied one.

    Returns: map
    key is stat name, value is value. Keys are ['isk-daemon uptime', 'Number of databases', 'Total memory usage', 'Resident memory usage', 'Stack memory usage']

    Since: 0.7

    isValidDb(dbId)

     

    Return whether database space id has already been defined

    Parameters:
    • dbId (number) - Database space id.
    Returns: boolean
    True if exists

    Since: 0.7

    getIskLog(window=30)

     

    Returns the last lines of text in the iskdaemon instance log

    Parameters:
    • window (number) - number of lines to retrieve
    Returns: string
    text block

    Since: 0.9.3


    Comments