Table of Contents

Javascript binding API - Ethumb - Thumbnail images

Back to the JS EFL page

The Ethumb library allows the creation of thumbnail images of files.

Functions

initClient()

Syntax

efl.Ethumb.initClient();

Initializes the Ethumb client library.

connectClient(callback)

Syntax

function mycallback(client, success) { ... };
efl.Ethumb.connectClient(mycallback);

Parameters

Return value

Connects to Ethumb server and return the client instance.

This is the “constructor” of Ethumb Clients, where everything starts.

If server was down, it is tried to start it using DBus activation, then the connection is retried.

This call is asynchronous and will not block, instead it will be in “not connected” state until callback is called with either success or failure. On failure, then no methods should be called. On success you're now able to setup and then ask generation of thumbnails.

Usually you should listen for server death/disconenction with the setOnServerDieCallback() method.

shutdownClient()

Syntax

efl.Ethumb.shutdownClient();

Shuts down the Ethumb client library.

Ethumb Client methods

cancelAllGenerate()

Syntax

clientObj.cancelAllGenerate()

Ask server to cancel generation of all thumbnails.

cancelGenerate(id, callback)

Syntax

function callback(success) {...};
clientObj.cancelGenerate(id, callback);

Parameters

Ask server to cancel generation of a thumbnail.

disconnect()

Syntax

clientObj.disconnect();

Disconnect the client, releasing all client resources.

This is the destructor of Ethumb Client, after it's disconnected the client handle is now gone and should not be used.

existsThumb(callback)

Syntax

function callback(client, existsInfo, exists) {...};
clientObj.existsThumb(callback);

Parameters

Return value

Checks whenever file already exists (locally!)

This will check locally (not calling server) if thumbnail already exists or not, also calculating the thumbnail path. Path must be configured with setFile() before using it and the last set file will be used!

freeFile()

Syntax

clientObj.freeFile();

Reset previously set file to NULL.

generate(callback)

Syntax

function callback(client, id, file, key, thumb_path, thumb_key, success) {...};
var id = clientObj.generate(callback);

Parameters

Return value

Ask server to generate a thumbnail.

This process is asynchronous and will report back from main loop using callback. One can cancel this request by calling cancelGenerate() or cancelAllGenerate(), but not that request might be processed by server already and no generated files will be removed if that is the case.

This will not check if file already exists, this should be done by explicitly calling existsThumb() That is, this function will override any existing thumbnail.

getFile()

Syntax

var info = clientObj.getFile();

Return value

Gets the info from setFile() method.

getThumbAsync(callback)

Syntax

function callback(client, path, key) {...};
clientObj.getThumbAsync(callback);

Parameters

Return value

setFile(path, key)

Syntax

var ok = clientObj.setFile(path, key);

Parameters

Return value

Set source file to be thumbnailed.

Calling this function has the side effect of resetting values auto-generated with existsThumb() method.

setOnServerDieCallback(callback)

Syntax

function callback(client) { ... }
clientObj.setOnServerDieCallback(callback);

Parameters

Sets the callback to report server died.

When the server dies there is nothing you can do, just release resources with disconnect() and probably try to connect again.

Usually, you should set this callback and handle this case, it does happen!

Ethumb Client Exists methods

cancel()

Syntax

existsObj.cancel();

Cancel an ongoing exists request.

check()

Syntax

existsObj.check();

Check if an exists request was cancelled.