SI520

/usr/bin/perl w use strict use CGI use CGI::Carp qwfatalsToBrowser use GD use DBI ............................................... qqqqqqqqqqqqqqqQQQQQQQQQQQQQQQUUUUUUUUTTTTTTT.. 11111111111111111111111111111111111111111111111 77777777777777777777777777777777777777777777777 name:seth qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq professional interests:I write computer programs, these days for M Publishing ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ software skills:I have a about 10 years of experience creating web applications. Ive used Photoshop, Flash, Illustrator, but its been a while. These days I write perl / php / javascriptjquery and so forth. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ttttttttttttttttttttttttttttttttttttttttttttt ttttttttttttttttttttttttttttttttttttttttttttt KKtttttttttttttttttttttttttttttKKtttttttttttt expectations: Id link to learn to make art that isnt so messy KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK this was created by the following program well, mostly which I wrote in 2004 GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGGGGGGGGGGGFFFFFFFFFFFFFFFFFFFF ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX............. my dbh = DBIconnectdbi:mysql:serth:mysql.serth.org,username,password or die couldnt connnect to db: :nn my q = new CGI my debug = 0 get/set session info require session.pl my url = wtp.cgi my access = wtp.cgi my session = &session::testsessionq, url, access my modifier, image, readfile, colorhash, totalcount, height, width, invert, writechars, brightness, totalcolor, title, size the characters we can acknowledge my @letters = a .. z, , A .. Z, 0 .. 9, . make higher for bigger rectangles, 1 = 1 pixel if qparammodifier { modifier = qparammodifier modifier = 100 } else { modifier = 10 } my text = qparamtext if defined text { &showformq } else { text = substrtext, 0, 400 text =~ s/|||||||||||//g first we need to see if theyve made too many images today "aq invert = true if defined qparaminvert writechars = true if defined qparamwritechars dont even try to write text into a 1 pixel space undef writechars if modifier == 1 readfile = &createreadfile readfile = readfile..png totalcount = &totalcount@letters, text die You entered 3 or less characters or did something weird. sorry.n if totalcount 4 if qparamlayout =~ /vertical/ { height, width = &dimensionstotalcount } else { width, height = &dimensionstotalcount } if qparambrightness { brightness = qparambrightness } else { brightness = 85 default color offset value } colorhash, image = &buildhashheight, width, @letters, modifier, invert, brightness if debug { for keys %colorhash { print key: value: colorhash{} } } size = &writeimage, readfile, width, colorhash, text, modifier, writechars totalcolor = 64 Maybe someday we can change this to add more, but for now leave it. if qparamtitle { title = qparamtitle title =~ s/|||||||||| //g } else { title = readfile } &logq, readfile, text, invert, modifier, brightness, totalcolor, title, size, height, width, session forward them to the gallery why doesnt this work right print qredirectgallery.cgi } sub createreadfile { use Time::localtime my t = localtime my year = tyear+1900 my month = tmon+1 my day = tmday my @chars = A .. Z, a .. z, 0 .. 9 my filename = join, @chars[ map { rand @chars } 1 .. 8 ] filename = year.month.day..filename return filename } sub buildhash { build a hash of letters=GD colorspace colors my height = shift my width = shift my letters = shift my modifier = shift my invert = shift my bright = shift create the image my image = new GD::Image width*modifier, height*modifier or die couldnt create image n each anon array in this hash represents the RBG values in an individual color. Later, we mutliply each of these by a number to get the actual values. For instance, [1,2,3] multiplied by 85 would give an RGB of [85,170,255]. You could also do a multiplier of say 20 to get [20,40,60]. This would result in a much darker final image then if you use 85. my @numbers = [0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 0, 3], [0, 1, 0], [0, 1, 1], [0, 1, 2], [0, 1, 3], [0, 2, 0], [0, 2, 1], [0, 2, 2], [0, 2, 3], [0, 3, 0], [0, 3, 1], [0, 3, 2], [0, 3, 3], [1, 0, 0], [1, 0, 1], [1, 0, 2], [1, 0, 3], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 1, 3], [1, 2, 0], [1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 3, 0], [1, 3, 1], [1, 3, 2], [1, 3, 3], [2, 0, 0], [2, 0, 1], [2, 0, 2], [2, 0, 3], [2, 1, 0], [2, 1, 1], [2, 1, 2], [2, 1, 3], [2, 2, 0], [2, 2, 1], [2, 2, 2], [2, 2, 3], [2, 3, 0], [2, 3, 1], [2, 3, 2], [2, 3, 3], [3, 0, 0], [3, 0, 1], [3, 0, 2], [3, 0, 3], [3, 1, 0], [3, 1, 1], [3, 1, 2], [3, 1, 3], [3, 2, 0], [3, 2, 1], [3, 2, 2], [3, 2, 3], [3, 3, 0], [3, 3, 1], [3, 3, 2], [3, 3, 3] my @colors create the GD color table if debug { print the numbers: } for @numbers { if debug { print [0], [1], [2] } my color = imagecolorAllocate [0]*bright, [1]*bright, [2]*bright push @colors, color } if debug { print br the colors: @colorsbr } reverse the letters array if so desired if defined invert { @letters = reverse@letters } my %colorhash my i=0 build the letters=GD colorspace hash for @letters { colorhash{} = colors[i] i++ } return%colorhash, image } sub write { my image = shift the GD image object my readfile = shift name of the file to be created my width = shift image width my colorhash = shift the hash of characters = GD colorspace color my text = shift the text to process my m = shift the size modifier my writechars = shift param to write the character inside the rectangle graphic the plan is to write row by row depending on the width of the image. When weve reached the width, do it carrage retrun style and start the next row. All this depends on the size modifier too. my pngfile = readfile my x1 = 0 my y1 = 0 my @characters = split //, text for my char @characters { if defined colorhash{char} { my x2 = x1+m my y2 = y1+m my color = colorhash{char} imagefilledRectanglex1, y1, x2, y2, color if debug { print color: color char: charbr } if defined writechars { this is white... i guess need to make another table that makes the letters a color just slightly different then the rectangle color... which means a whole other color table... my letter = imagecolorAllocate255, 255, 255 GD::Image::stringimage, gdTinyFont, x1, y1, char, letter } x1 = x1+m if x2 == width*m { first row is done, go to the next y1 = y1+m x1 = 0 } } } print/create the image pngfile = ../pngs/.pngfile open OUTFILE , pngfile binmode OUTFILE whatever print OUTFILE imagepng close OUTFILE if debug { print brpngfilebr } get the size for the database my bytes = s pngfile my size = bytes/1024 size = intsize return size } .................................................... 0000000000000000000000000000000000000000000000000000 .............................................................................................................................................................................................................................................................................................................