[Xitami] Xitami as a service

RPO rolinger1 at hotmail.com
Tue Sep 19 04:22:53 CEST 2006


Hey Ingo,

GD is not a function of Xitami, but rather a function of perl and perl is
only called when the CGI process is activated.  I am using GD for image
altering and image generation.  Here is a function I am using to generate
images out of a font - a method for "guarantying" the user sees the font you
want them to see on your web page.   But alter the code a bit and you can
create images in a variety of ways.

Hope this example helps.  Others could probably code a better version, but
mine is sufficient for what I need.
-Russel

Win 32 Perl v5.8.3 running on Xitami v2.4d9 on Win2K Advanced Server
    - GD Module: v2.30
    - GDTextUtil v0.86
    - Font-TTFMetrics v0.1

sub gdImage {
   ### USAGE CALL
   ### &gdImage("some text",$fontColor1,$fontColor2,$fontType,13) ;
   ###     - I prefine all my fonts, colors, etc in another sub routine that
is called
   ###     - in any script that outputs HTML.

   my $varText = $_[0] ;
   my $varbColor = $_[1] ;
   my $varfColor = $_[2] ;
   my $fontType = $_[3] ;
   my $fontSize = $_[4] ;
   my $fileType = $_[5] ;

   ### Remove spaces & white space
   $varText =~  s/[^\w\s]//g ;

   ### create file name from text
   ### append any character to front for quick font changes
   ###  - to change fonts, edit prepended character and change $fontType
passed to function
   ###  -
   my $fileName = $varText ;
   $fileName =~ s/ /_/g ;
   $fileName = "A_" . $fileName . ".jpg" ;

   ### Check if image file already exists
   ###      - if exist, display image
   ###      - if not exist, create image and store it
   ###
   ###      This method requires a file only be created once
   ###
   if (-e "/xitami/htdocs/images/gifs/$fileName") {
      print qq{<img src="/images/gifs/$fileName" border="0" alt="$varText">}
;
   } else {
      use GD ;
      use Font::TTFMetrics ;

      ### set background color
      ### for easy use, colors are passed in RBG hex code, but passed with
spaces
      ###    - ie: $varbColor = "A5 B4 67"
      my @bColors = split(/ /,$varbColor) ;
         $rb = hex $bColors[0] ;
         $gb = hex $bColors[1] ;
         $bb = hex $bColors[2] ;

      ### set FONT color
      ### for easy use, colors are passed in RBG hex code, but passed with
spaces
      ###    - ie: $varbColor = "A5 B4 67"
      my @fColors = split(/ /,$varfColor) ;
         $rf = hex $fColors[0] ;
         $gf = hex $fColors[1] ;
         $bf = hex $fColors[2] ;

      #### retrieve font info:
      ###   - type,
      ###   - length, retrieving character length is important
      ###       - font length allows you to create image just big enough to
hold all characters
      $fontMetrics = Font::TTFMetrics->new($fontType);
      $fontLength = int($fontMetrics->string_width($varText));
      $fLength = $fontLength * ($fontSize + 2) * 96 / ( 72 * 1024 ) ;

      #### create new image, pad the fontSize with offset of 6
      my $img = GD::Image->new($fLength,$fontSize + 6) ;

      ### set new image properties
      $backColor = $img->colorAllocate($rb,$gb,$bb);
      $fontColor = $img->colorAllocate($rf,$gf,$bf);

      $img->transparent($backColor);
      $img->interlaced('true');

      ### Example of parameters required by stringFT:
      ###       -
gdim->stringFT($color,$fontname,$fontSize,0,$xPixel,$yPixel,$line) ;
      my @bounds =
$img->stringFT($fontColor,$fontType,$fontSize,0,0,0,$varText) ;

      ### Use above dimensions to center text

$img->stringFT($fontColor,$fontType,$fontSize,0,(($fLength-$bounds[2])/2),16
,$varText);

      ### save image.
      open(PICTURE, ">/xitami/htdocs/images/gifs/$fileName") or die "Cannot
Create File" ;
      binmode PICTURE;
      print PICTURE $img->jpeg(100);
      close PICTURE;

      ### print image to html
      print qq{<img src="/images/gifs/$fileName" border="0" alt="$varText">}
;
   }
}


----- Original Message ----- 
From: "Ingo" <haasi at earthlink.net>
To: "'Xitami Users General Discussion'" <xitami at lists.xitami.org>
Sent: Sunday, September 17, 2006 3:46 PM
Subject: RE: [Xitami] Xitami as a service


> Hello Ron,
> If you get GD to generate images with XITAMI, please pass on what you have
> done to resolve it. I have been trying on and off for the last few months
to
> no avail, I even installed Apache thinking maybe it was something with
> xitami but I am more inclined to believe that GD only runs on a Lenox box.
> My test.php page tells me GD is running however it will not generate the
> data in the image file.
>
>      Ingo
>
> -----Original Message-----
> From: xitami-bounces at lists.xitami.org
> [mailto:xitami-bounces at lists.xitami.org] On Behalf Of Ron Ackerman
> Sent: Sunday, September 17, 2006 5:13 PM
> To: 'Xitami Users General Discussion'
> Subject: RE: [Xitami] Xitami as a service
>
> Johannes,
>
> Thanks I got it running fine and got the Apache service disabled. Might
run
> Apache on a different port or I might turn on IIS on a different port.
It's
> nice to have 3 to choose from but since I grew up with Xitami I feel more
> confident with it, just wish it had better intrigration with ASP. And I
> noticed that Xitami runs faster than Apache for PHP. My pages loaded about
> twice as fast. I do have one small problem with my PHP and GD that I need
to
> resolve.
>
> Ron
>
> -----Original Message-----
> From: xitami-bounces at lists.xitami.org
> [mailto:xitami-bounces at lists.xitami.org] On Behalf Of Johannes Prost
> Sent: Sunday, September 17, 2006 2:43 PM
> To: Xitami Users General Discussion
> Subject: RE: [Xitami] Xitami as a service
>
> Hi Ron,
>
> as Alex wrote already in his post, you ONLY need to call xisrv.exe in a
DOS
> box like in the description inside of the xitami dir with xiserv.exe -i
> which installs the service. After that you can configure the service from
> the controll panel. Can't desribe it, as I don't have 2003.
> That's really all what you have to do to run it as a service.
> The xicpl32 is only for the icon to showup in the controll panel. Not
needed
> to run the service.
>
> Johannes
>
>
> > Reason I ask is that I have a Win2003 server set up with Apache and
> > have decided I don't like Apache so I'm going back to Xitami and I
> > want to make sure it runs as a service. Sometimes the server farm
> > updates the server and reboots it. If I don't have Xitami running as a
> > server it doesn't start until I log in.
> >
> > -----Original Message-----
> > From: xitami-bounces at lists.xitami.org
> > [mailto:xitami-bounces at lists.xitami.org] On Behalf Of Ron Ackerman
> > Sent: Saturday, September 16, 2006 5:21 PM
> > To: 'Xitami Users General Discussion'
> > Subject: RE: [Xitami] Xitami as a service
> >
> > This is 2006 thanks.
> >
> > -----Original Message-----
> > From: xitami-bounces at lists.xitami.org
> > [mailto:xitami-bounces at lists.xitami.org] On Behalf Of Alex Barna
> > Sent: Saturday, September 16, 2006 5:07 PM
> > To: Xitami Users General Discussion
> > Subject: Re: [Xitami] Xitami as a service
> >
> > Hi Ron,
> >
> > Ron Ackerman wrote:
> >
> >>  Hey if I didn't download the Windows Service version are the files
> >> there to start Xitami as a service? Are all the files there that I
> >> need? I tried to download the service ver and it just errors out.
> >>
> >>  Ron
> >
> > That was covered  back in 2004.
> > Here is a copy. of the instructions that should work with any version
> > that contains the required files.
> >
> > Alex B.,
> >
> > From: Steve Winn
> > Subject: RE: [Xitami] Installing Xitami as a service
> >
> > The older version 2.4d9 that had the installer was a lot simpler to
> > figure out, but the newer open source versions are just as easy once
> > you figure out what to do (guess that's true with anything heh).
> >
> > 1. Unzip the xitami archive to c:\xitami 2. In the \xitami\win32
> > folder, copy the xicpl32.cpl to your
> > \windows\system32 directory.
> > Copy xisrv32.exe to the \xitami directory.
> > 3. Goto a command prompt, type "cd\xitami" to change to the xitami
> > directory. Then type "xisrv32.exe -i" to install the service. The
> > service is now installed.
> >
> > To uninstall the service you can run "xisrv32.exe -u".
> >
> > The service will automatically start when you reboot, or go into
> > services and start it manually, or open the xitami control panel and
> > start it there.
> >
> > If you are going to be accessing folders or files over the network,
> > you may need to go into services and tell the xitami service to logon
> > with an account that has access.
> >
> > Steve
> >
> >
> >
> > --
> > Xitami Users Mailing List -- For Xitami support To unsubscribe:
> > http://lists.xitami.org/mailman/listinfo/xitami
> >
> > --
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.1.405 / Virus Database: 268.12.4/449 - Release Date:
> > 9/15/2006
> >
> >
> > --
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.1.405 / Virus Database: 268.12.4/449 - Release Date:
> > 9/15/2006
> >
> >
> >
> > --
> > Xitami Users Mailing List -- For Xitami support To unsubscribe:
> > http://lists.xitami.org/mailman/listinfo/xitami
> >
> > --
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.1.405 / Virus Database: 268.12.4/449 - Release Date:
> > 9/15/2006
> >
> >
> > --
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.1.405 / Virus Database: 268.12.4/449 - Release Date:
> > 9/15/2006
> >
> >
> >
> > --
> > Xitami Users Mailing List -- For Xitami support To unsubscribe:
> > http://lists.xitami.org/mailman/listinfo/xitami
> >
>
>
>
> --
> Xitami Users Mailing List -- For Xitami support To unsubscribe:
> http://lists.xitami.org/mailman/listinfo/xitami
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.12.4/449 - Release Date: 9/15/2006
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.12.4/449 - Release Date: 9/15/2006
>
>
>
> --
> Xitami Users Mailing List -- For Xitami support
> To unsubscribe: http://lists.xitami.org/mailman/listinfo/xitami
>
>
> --
> Xitami Users Mailing List -- For Xitami support
> To unsubscribe: http://lists.xitami.org/mailman/listinfo/xitami
>



More information about the Xitami mailing list