WebTools

 view release on metacpan or  search on metacpan

lib/modules/ImagePwd.pm  view on Meta::CPAN

package ImagePwd;

use Image::Magick;

use strict;

##############################################
# ImagePwd module written by Julian Lishev
# This module is part of WebTools package!
# Privacy and terms are same as WebTools!
##############################################
# Prerequirment: Image::Magick (PerlMagick)
##############################################


=head2 $img = ImagePwd::new (%inp);

 %inp hash can contain follow members:
 
   len      - Count of password string.
   width    - Width of generated image.
   height   - Height of generated image.

lib/modules/ImagePwd.pm  view on Meta::CPAN

 $cx = rand(10);
 my $a_cx = $cx * $len;
 for ($i=0;$i<$len;$i++)
  {
   my $sz = $obj->f_min() + rand($obj->f_max() - $obj->f_min());
   push (@pnts,$sz);
   $i_x += $sz;
  }
 my $addl = $cx;
 $cx = ($width/2) - (($i_x+$a_cx)/2);
 my $image = Image::Magick->new(compression=>'LosslessJPEG',quality=>$quality);
 $image->Set(size=>$width.'x'.$height);
 my $bgcolor = $f_bgcolor || _generatebgcolor();
 my $color = $f_color || _choosecolor($bgcolor);
 $image->Set(antialias=>'True');
 $image->ReadImage('xc:'.$bgcolor);
 for ($i=0;$i<$len;$i++)
  {
   my $char = substr($str,$i,1);
   my $sz = $pnts[$i];
   my $rot = int(rand(10)) > 5 ? (-1)*rand($rot) : rand($rot);



( run in 1.329 second using v1.01-cache-2.11-cpan-beeb90c9504 )