[Clipart] [Cctools-cchost] function for generating png thumbnails from svg files

Victor Stone fourstones.net at gmail.com
Sun Nov 4 13:32:22 PST 2007

On 11/3/07, Roan Horning <roan at horning.us> wrote:
> I've written a php function that uses inkscape's command line interface
> to generate a png thumbnail of an svg file.

that's great and we definitely want to include in cchost, however with
a big caveat because many shared hosting sites disable exec() from php
script so while technically it's not a generic php solution, enough
folks are hungry for it as you've spec'd it.

> I've seen some conversation in the lists about generating and keeping
> thumbnails on upload. Is this what we want to do, or do we want to
> generate them on the fly (maybe using some kind of cache to keep the
> processor overhead down)? If we are going to do it on upload, where is
> the best place in the code to call this function?

There are two things to consider here that I can think of

1) caching YES.

You want to watch for cchost events
UPLOAD_DONE (to create the thing)
UPLOAD_DELETE (to clear the cache)
FILE_DONE (to watch for file adds/deletes/replaces)

remember that an upload record can have multiple images, each with
it's own thumbnail. Now you may make an executive decision to only
thumbnail the first one and that's totally cool. This is the decision
I came to when doing the flash-mp3 player and playlists: that only the
'top' file in the upload record is retrieved when the user requests

2) keep the actual thumbnail creation code isolated from everything
else. This allows for Inkspace dependency to be easily isolated and
replaced, but also allows for us to use that smarts in other areas of
the code (like when a user uploads an avatar that's too big, instead
of rejecting it we should shrink it to the right size)


More information about the clipart mailing list