f66860 | 2000-03-02 | Martin Nilsson | |
|
2e0a35 | 1999-12-09 | Martin Nilsson | |
|
37bdda | 1999-05-18 | Per Hedbor | | #include <module.h>
inherit "module";
|
3b85e9 | 1999-11-15 | Per Hedbor | | constant thread_safe=1;
|
37bdda | 1999-05-18 | Per Hedbor | |
roxen.ImageCache the_cache;
|
d83355 | 2000-05-01 | Martin Nilsson | | constant cvs_version="$Id: cimg.pike,v 1.16 2000/05/01 06:18:02 nilsson Exp $";
|
76fd09 | 2000-04-06 | Mattias Wingstedt | | constant tagdesc="Provides the tag <tt><cimg></tt> that can be used "
"to convert images between different image formats.";
|
37bdda | 1999-05-18 | Per Hedbor | |
|
c043f8 | 2000-02-10 | Martin Nilsson | | constant module_type = MODULE_PARSER;
constant module_name = "Image converter";
constant module_doc = tagdesc;
|
37bdda | 1999-05-18 | Per Hedbor | |
|
2e0a35 | 1999-12-09 | Martin Nilsson | | TAGDOCUMENTATION
|
71a18b | 2000-02-02 | Jonas Wallden | | #ifdef manual
|
2e0a35 | 1999-12-09 | Martin Nilsson | | constant tagdoc=(["cimg":"<desc tag>"+tagdesc+"</desc>"]);
#endif
|
37bdda | 1999-05-18 | Per Hedbor | | 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 | | {
|
36eceb | 2000-01-30 | Per Hedbor | | mapping a=
([
|
d83355 | 2000-05-01 | Martin Nilsson | | "src":(args->src?Roxen.fix_relative( args->src, id ):0),
|
37bdda | 1999-05-18 | Per Hedbor | | "quant":args->quant,
|
77926b | 2000-04-11 | Per Hedbor | | "crop":args->crop,
|
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 | | ]);
|
77926b | 2000-04-11 | Per Hedbor | |
a["background-color"] = id->misc->defines->bgcolor
|| "#eeeeee";
|
c52692 | 1999-05-18 | Per Hedbor | | foreach( glob( "*-*", indices(args)), string n )
a[n] = args[n];
|
77926b | 2000-04-11 | Per Hedbor | |
|
34a9b8 | 1999-08-06 | Peter Bortas | | return a;
}
string tag_cimg( string t, mapping args, RequestID id )
{
mapping a = get_my_args( args, id );
|
37bdda | 1999-05-18 | Per Hedbor | | args -= a;
|
54d2fa | 1999-11-24 | Per Hedbor | | args->src = query_internal_location()+the_cache->store( a,id );
|
36eceb | 2000-01-30 | Per Hedbor | | if( mapping size = the_cache->metadata( a, id, 1 ) )
|
37bdda | 1999-05-18 | Per Hedbor | | {
args->width = size->xsize;
args->height = size->ysize;
}
|
d83355 | 2000-05-01 | Martin Nilsson | | return Roxen.make_tag( "img", args );
|
37bdda | 1999-05-18 | Per Hedbor | | }
|
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 | | }
|