Roxen.git / server / modules / graphics / cimg.pike

version» Context lines:

Roxen.git/server/modules/graphics/cimg.pike:1:   // This is a roxen module. Copyright © 1999 - 2000, Roxen IS.   //      #include <module.h>   inherit "module";   constant thread_safe=1;      roxen.ImageCache the_cache;    - constant cvs_version = "$Id: cimg.pike,v 1.31 2000/09/19 21:47:20 kuntri Exp $"; + constant cvs_version = "$Id: cimg.pike,v 1.32 2000/11/21 13:14:49 per Exp $";   constant module_type = MODULE_TAG;   constant module_name = "Image converter";   constant module_doc = "Provides the tag <tt>&lt;cimg&gt;</tt> that can be used "   "to convert images between different image formats.";         mapping tagdocumentation() {    Stdio.File file=Stdio.File();    if(!file->open(__FILE__,"r")) return 0;    mapping doc=compile_string("#define manual\n"+file->read())->tagdoc;
Roxen.git/server/modules/graphics/cimg.pike:119:   void flush_cache() {    the_cache->flush();   }      string status() {    array s=the_cache->status();    return sprintf("<b>Images in cache:</b> %d images<br />\n<b>Cache size:</b> %s",    s[0]/2, Roxen.sizetostring(s[1]));   }    - mapping generate_image( mapping args, RequestID id ) + array(Image.Layer) generate_image( mapping args, RequestID id )   { -  +  array layers; +  mapping opts = ([]); +  if( args["process-all-layers"] ) +  opts->draw_all_layers = 1; +     if( args->data ) -  return roxen.low_decode_image( args->data ); +  layers = roxen.decode_layers( args->data, opts );    else -  return roxen.low_load_image( args->src, id ); +  layers = roxen.load_layers( args->src, id, opts ); +  +  +  if( args["exclude-layers"] ) +  { +  foreach( args["exclude-layers"] / ",", string match ) +  foreach( layers, Image.Layer lay ) +  if( glob( match, lay->get_misc_value( "name" ) ) ) +  lay->set_misc_value( "visible", 0 );    }    -  +  if( args["include-layers"] ) +  { +  foreach( args["include-layers"] / ",", string match ) +  foreach( layers, Image.Layer lay ) +  if( glob( match, lay->get_misc_value( "name" ) ) ) +  lay->set_misc_value( "visible", 1 ); +  } +  +  array res = ({}); +  foreach( layers, Image.Layer l ) +  { +  if( l->get_misc_value( "visible" ) ) +  res += ({ l }); +  } +  return res; + } +    mapping find_internal( string f, RequestID id )   {    return the_cache->http_file_answer( f, id );   }      mapping get_my_args( mapping args, RequestID id )   {    mapping a=    ([    "quant":args->quant,
Roxen.git/server/modules/graphics/cimg.pike:152:    "dither":args->dither,    "gamma":args->gamma,    "data":args->data,    ]);       if( args->src )    catch    {    a->src = Roxen.fix_relative( args->src, id );    Stat st = id->conf->stat_file(a->src, id) || file_stat(a->src); -  if (st) { +  if (st) +  { +  string fn = id->conf->real_file( a->src, id ); +  if( fn ) Roxen.add_cache_stat_callback( id, fn, st[ST_MTIME] );    a->mtime = (string) (a->stat = st[ST_MTIME]);    a->filesize = (string) st[ST_SIZE];    }    };       a["background-color"] = id->misc->defines->bgcolor || "#eeeeee";       foreach( glob( "*-*", indices(args)), string n )    a[n] = args[n];