[RFC] Dynamic image generator handler

2002-05-09 Thread Michael A Nachbaur

This is an request for comments.  If you don't care about dynamic image
generation with mod_perl, or don't care about offering or reading about
suggestions, you can safely ignore this.  Also, be forewarned, this was
written in StarOffice, and then copied/pasted into my email program, and
hand tweaked, so some things may not have made the transition properly.

Dynamic Image Manipulator
-

*) Overview

This is a mod_perl handler, not directly tied in with my content
management system, but is/will be used extensively by it. The premise is
to dynamically generate images, cache them, and present them to browser
clients. The URI, as well as Apache configuration directives, is used to
determine what is to be generated.

*) Basic Uses

The most basic uses of this application will to dynamically generate TTF
text for titles, buttons, sidebars, etc. The current version of this
code does this, and quite well. Foreground and background colors, font
name (with bold/italic support), font size, image size (or automatically
detected based on the size of the text), and rotation.

The basic text support could be extended to allow for images to be
overlayed on the text (or placed under the text), or stretch images
similarly to how Enlightenment displays window manager themes.

Other uses planned would be to manipulate existing images. For instance,
if an image on a website needs a thumbnail, medium size and full-size
view, normally a person must make all versions by hand. If any
formatting needs to be done, like borders or drop-shadows, this
increases complexity. If a person could just drop an image in a
directory, and link to that image, the image could automatically be
resized, borders added, drop shadows put in place. The resulting image
would then be cached, and outputted.

*) URI Arguments

Information about what is to be done is passed through the URI. This
works for simple tasks like text display, but if anything more
complicated is to be done, external configuration files must be used.
We'll get to that in a bit.

Essentially, arguments are passed using the PATH_INFO HTTP header. We
want the browser to think this is an actual file, instead of a
dynamically generated image, so that the browser is more inclined to
cache the content. So, a typical query would be:

  http://localhost/genText/font=ArialBold;size=24;fgcolor=#ff;
  bgcolor=#00;rotate=90;text=This+Is+The+Text

Resizing an image could be accomplished by doing:

  http://localhost/genImage/source=/images/ducks.jpg;scale-ratio=1:1;
  width=120;height=80;border-size:1px;border-color:#00;
  shadow-color:#00;shadow-angle:270;shadow-distance:5px

This would resize an image to the indicated width/height. The
"scale-ratio" argument would limit the width/height ratio, so the
maximum dimension would be used. The other attributes are obvious.

*) Configuration Files
Lets assume that we are going to scale an image, add borders to it which
consist of other images, and add text captions over the image. This
would result in such a long URI, that browsers would probably truncate
it. In addition, providing direct access to the browser opens up
possibilities for DoS attacks. Therefore, a configuration file should be
used. The config file must be flexible enough to allow a web page to
provide various input, but have certain defaults set, and restricted.

The proposed solution would be to have a config file that has preset
default templates that the input arguments augment. For instance:


  

   
border-style: solid;
border-color: #00;
border-width: 1px;
shadow-distance: 5px;
shadow-angle: 270; 
shadow-color: #00;
  
  


  
  
  /images/watermark.gif


  
font-face: Arial;
font-size: 10px;
color: #00;
border-style: solid;
border-color: #ff;
opacity: 80%;
text-align: right;
  
  Copyright © 2002 Foo Bar Industries


  
font-face: Arial;
font-size: 14px;
color: #ff;
text-align: left;
position: top;
  
  

  


As you can see, the above configuration file uses CSS. It makes sense to
leverage that, although I'm not certain how difficult it would be to
interface with CSS files. As far as I know, there are Perl CSS parsers,
but I have yet to use them. The configuration for a preset config
template would be layered, so the earlier the definition, the lower the
layer is. The real important part here, is the "name" attribute of any
element, as this identifies where input can be indicated. The above
preset could be used by invoking the following URI.

  http://localhost/genImage/preset=thumbnail-image;src=/images/ducks.jpg

As you can see, the preset is invoked by passing it's name as an
attribute, and any element that has a name attribute, it's value can be
provided on the 

mod_perl2: nmake test crashes apache

2002-05-09 Thread Bjoern Hoehrmann

Hi,

Perl:  version 5.61, ActiveState ActivePerl Build 631
mod_perl2: about one moth old CVS snapshot and
   todays modperl-2.0_20020509222354.tar.gz
Apache:2.0.35 and 2.0.36
Compiler:  VisualStudio.NET EA, Service Pack 1
OS:Win2k Professional, Service Pack 2

Apache builds and installs fine, mod_perl2 builds fine but running
`nmake test` crashes the instance of apache2 created by the TEST script.
Output of `nmake test` is

  % nmake test
  
  Microsoft (R) Program Maintenance Utility Version 7.00.9466
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  cd "src/modules/perl" && nmake
  
  Microsoft (R) Program Maintenance Utility Version 7.00.9466
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  C:\Perl\bin\perl.exe -Iblib\arch -Iblib\lib  t/TEST -clean
    C:\Perl\bin\perl.exe -Iblib\arch -Iblib\lib  t/TEST
  *** : cannot build c-modules without apxs
  c:/winapp/apache2/bin/Apache.exe  -d C:/b/modperl-2.0/t -f 
C:/b/modperl-2.0/t/conf/httpd.conf -DAPACHE2 -DPERL_USEITHREADS
  using Apache/2.0.36 (winnt MPM)
  waiting for server to start: 00:00[Fri May 10 03:09:42 2002] [info] 12 Apache:: 
modules loaded
  [Fri May 10 03:09:42 2002] [info] 5 APR:: modules loaded
  [Fri May 10 03:09:42 2002] [info] base server + 6 vhosts ready to run tests
  [Fri May 10 03:09:42 2002] [info] 11 Apache:: modules loaded
  [Fri May 10 03:09:42 2002] [info] 5 APR:: modules loaded
  [Fri May 10 03:09:42 2002] [info] base server + 6 vhosts ready to run tests
  END in modperl_extra.pl, pid=2596
  END in modperl_extra.pl, pid=2596
  END in modperl_extra.pl, pid=2596
  END in modperl_extra.pl, pid=2596
  END in modperl_extra.pl, pid=2596
  END in modperl_extra.pl, pid=2596
  END in modperl_extra.pl, pid=2596
  waiting for server to start: ok (waited 1 secs)
  server Voyager:8529 started
  server Voyager:8530 listening (TestDirective::perlmodule)
  server Voyager:8531 listening (TestDirective::perlrequire)
  server Voyager:8532 listening (TestProtocol::echo)
  server Voyager:8533 listening (TestProtocol::echo_filter)
  server Voyager:8534 listening (TestProtocol::eliza)
  server Voyager:8535 listening (TestFilter::input_msg)
  apache\cgihandler...ok
  apache\compat...ok
  apache\compat2..ok

next test is apache\conftree, Windows tells something like

  The instruction at "0x2800e66f" referenced memory at "0x0018".
  The memory could not be "read".

next test is apache\constants, it's ok but all subsequent tests fail,
because the server has gone. When I skip apache\conftree apache\post
will crash the webserver.

I guess this is a bug somewhere in mod_perl, any advice?



Re: Apache::Session

2002-05-09 Thread Perrin Harkins

Stathy G. Touloumis wrote:
>>You need to do some more debugging.  Problems with Apache::Session are 
>>usually due to scoping, so put in some debug statements to see that the 
>>session objects for the IDs having trouble are getting properly cleaned 
>>up (i.e. DESTROY is getting called).  It is possible to have problems 
>>with DB_File if it doesn't get untied after each request.
> 
> 
> Wouldn't the issue above (untie) be alleviated by restarting apache?

Probably.  There are some strange situations you can get into with 
DB_File if you don't untie (due to caching and lost updates), but you're 
right that the file locks would probably make the system hang if the 
session wasn't getting cleaned up.

I don't know what else could be causing your problem, but I would still 
suggest trying Apache::Session::File as a potential fix.

- Perrin




RE: Apache::Session

2002-05-09 Thread Stathy G. Touloumis

> You need to do some more debugging.  Problems with Apache::Session are 
> usually due to scoping, so put in some debug statements to see that the 
> session objects for the IDs having trouble are getting properly cleaned 
> up (i.e. DESTROY is getting called).  It is possible to have problems 
> with DB_File if it doesn't get untied after each request.

Wouldn't the issue above (untie) be alleviated by restarting apache?




Re: [BUG?] PerlSetVar in .htaccess segfaults w/ register_cleanup()

2002-05-09 Thread Stas Bekman

D.Kreft wrote:
...
> I am greeted with Netcape's "Document contains no data" error dialog
> box, and a segfault notice in the error log:
> 
>[Thu May  9 09:19:52 2002] [notice] child pid 25420 exit \
>signal Segmentation fault (11)
...
> Does anyone have any ideas about what's going wrong here? Any help
> would be greatly appreciated!

Probably not, without a back trace (from the Segfault) unless someone 
has had a similar problem and solved it before. See
http://perl.apache.org/preview/modperl-docs/dst_html/docs/1.0/guide/help.html#How_to_Report_Problems
on how to retrieve the backtrace.


__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com




[BUG | ANNOUNCE] Apache::Status segfault | EnglishSave

2002-05-09 Thread Ernest Lergon

Trying to use the 'Memory Usage' feature of Apache::Status, I came
across the English module. 

Using it in a mod_perl Module causes Apache::Status to segfault. It
turned out, that when omitting some vars, the segfault was gone. 

So I put up a little changed version of English - EnglishSave. 

For the more enlightened perl people I also put two strace logs on this
page:

http://www.virtualitas.net/perl/englishsave/

Please download the module for testing. The ZIP file includes a test
module and a raw startup.pl.

I don't plan to upload it to CPAN, because the problem might not be in
English.pm but in Apache::Status - or in the darkness beclouding my head
;-))

Ernest


-- 

*
* VIRTUALITAS Inc.   *  *
**  *
* European Consultant Office *  http://www.virtualitas.net  *
* Internationales Handelszentrum *   contact:Ernest Lergon  *
* Friedrichstraße 95 *mailto:[EMAIL PROTECTED] *
* 10117 Berlin / Germany *   ums:+49180528132130266 *
*
   PGP-Key http://www.virtualitas.net/Ernest_Lergon.asc




RE: Apache::Session

2002-05-09 Thread Stathy G. Touloumis

> You need to do some more debugging.  Problems with Apache::Session are
> usually due to scoping, so put in some debug statements to see that the
> session objects for the IDs having trouble are getting properly cleaned
> up (i.e. DESTROY is getting called).  It is possible to have problems
> with DB_File if it doesn't get untied after each request.

In my experience when untie is not called the request usually hangs.  It
seems odd that it would be isolated to just a few workstations though.  Is
it possible that the issue can be isolated to a child instance even with
different ID's?

Thanks for the response : )