37bdda | 1999-05-18 | Per Hedbor | | #include <module.h>
inherit "module";
inherit "roxenlib";
|
3b85e9 | 1999-11-15 | Per Hedbor | | constant thread_safe=1;
|
37bdda | 1999-05-18 | Per Hedbor | |
roxen.ImageCache the_cache;
|
54d2fa | 1999-11-24 | Per Hedbor | | constant cvs_version="$Id: cimg.pike,v 1.8 1999/11/24 15:03:05 per Exp $";
|
37bdda | 1999-05-18 | Per Hedbor | |
array register_module()
{
return
({
MODULE_PARSER,
"Image converter",
"Provides a tag 'cimg'. Usage: "
|
240b07 | 1999-09-14 | Johan Sundström | | "<cimg src=\"indata file\" format=outformat [quant=numcolors] [img args]>",
|
37bdda | 1999-05-18 | Per Hedbor | | 0,1
});
}
void start()
{
the_cache = roxen.ImageCache( "cimg", generate_image );
}
mapping generate_image( mapping args, RequestID id )
{
|
34a9b8 | 1999-08-06 | Peter Bortas | | if( args->data )
return roxen.low_decode_image( args->data );
else
return roxen.low_load_image( args->src, id );
|
37bdda | 1999-05-18 | Per Hedbor | | }
mapping find_internal( string f, RequestID id )
{
return the_cache->http_file_answer( f, id );
}
|
34a9b8 | 1999-08-06 | Peter Bortas | | mapping get_my_args( mapping args, object id )
|
37bdda | 1999-05-18 | Per Hedbor | | {
|
34a9b8 | 1999-08-06 | Peter Bortas | | mapping a=([
"src":(args->src?fix_relative( args->src, id ):0),
|
37bdda | 1999-05-18 | Per Hedbor | | "quant":args->quant,
|
c52692 | 1999-05-18 | Per Hedbor | | "format":args->format,
"maxwidth":args->maxwidth,
"maxheight":args->maxheight,
"scale":args->scale,
"dither":args->dither,
|
b941aa | 1999-06-25 | Per Hedbor | | "gamma":args->gamma,
|
34a9b8 | 1999-08-06 | Peter Bortas | | "data":args->data,
|
37bdda | 1999-05-18 | Per Hedbor | | ]);
|
c52692 | 1999-05-18 | Per Hedbor | | foreach( glob( "*-*", indices(args)), string n )
a[n] = args[n];
|
34a9b8 | 1999-08-06 | Peter Bortas | | return a;
}
string tag_cimg( string t, mapping args, RequestID id )
{
mapping a = get_my_args( args, id );
|
c52692 | 1999-05-18 | Per Hedbor | |
|
37bdda | 1999-05-18 | Per Hedbor | | args -= a;
|
54d2fa | 1999-11-24 | Per Hedbor | | args->src = query_internal_location()+the_cache->store( a,id );
|
37bdda | 1999-05-18 | Per Hedbor | | if( mapping size = the_cache->metadata( a, id, 1 ) )
{
args->width = size->xsize;
args->height = size->ysize;
}
return make_tag( "img", args );
}
|
698c12 | 1999-05-19 | Peter Bortas | |
string tag_cimg_url( string t, mapping args, RequestID id )
{
|
54d2fa | 1999-11-24 | Per Hedbor | | return query_internal_location()+the_cache->store(get_my_args(args,id),id);
|
698c12 | 1999-05-19 | Peter Bortas | | }
|