Re: The Histor of The Kewl Script

From: Date: Sun, 29 Jul 2001 17:37:16 +0000
Subject: Re: The Histor of The Kewl Script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-69303@lists.php.net to get a copy of this message
Look at what i did, its confusing, now, don't ask me to explain the stuff in the style sheet, I try and read back over it, and well i get confused, its untested agian, but i am sure it should work good, i made it while i was offline...hehe The method i use inside the style sheet, might be helpful some where else, e.g. A script that makes UserIDs, or something, i know i've thought about doing a system similar before, also could be used for bad things(password h@cks) <? /* * Copyright (c) 2000, 2001 * Maxim Maletsky, <maxim@maxim.cx>, * * www.maxim.cx, www.PHPBeginner.com * * * DISCLAMER * DO NOT BLAME, USE IT ON YOUR OWN RISK * - It's Open Source! * * This file can be used by you in any way you wish * as long as this author notice remains intact. */ $def_color = '000000'; $image = $image ? "http://$image" : ''; $max_zoom = 5; $zoom = (is_numeric($zoom) and $zoom>0 and $zoom<=$max_zoom) ? $zoom : 1; $img['PNG Official Logo'] = 'www.maxim.cx/test/pnglogo.png'; $img['Fancy Parrot'] = 'www.atalasoft.com/Images/stefan_full_rgba.png'; $img['Fancy Me'] = 'www.maxim.cx/img/maxim.png'; if($image != '') { $im = ImageCreateFromPNG($image); $imagesy = imagesy($im); $imagesx = imagesx($im); for($y=0;$y<$imagesy;$y++) { for($x=0;$x<$imagesx;$x++) { $color = ImageColorsForIndex($im, ImageColorAt($im, $x, $y)); $rgb = sprintf("%02x%02x%02x",$color['red'],$color['green'],$color['blue']); $imagecolors[$rgb]++; } } } ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta name="GENERATOR" content="Maxim Maletsky"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <style type="text/css"> <!-- BODY, P, H2, H3 { font-family: verdana,arial,helvetica,sans-serif; font-weight: 900; font-size:15px; color: #FFFFFF; } PRE { font-size:1px; line-height: 1px; color: #<?=$def_color?>; } H2 { font-size: 25px; } H3 { font-size: 17px; } A { color: #7B8FD6; font-size:17px;} A:visited { color: #800080; font-size:17px;} A:hover { text-decoration: none; font-size:17px;} <?php $letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; foreach($imagecolors as $color) { if($color > 1) { if(empty($colorstring)) { $colorstring = $letters[0].$letters[0]; } elseif($colorstring[sizeof($colorstring)] == $letters[sizeof($letters)]) { $colorstring .= $letters[0]; } else { for($i=0;$i<sizeof($letters);$i++) { if($colorstring[sizeof($colorstring)] == $letters[$i]) { $newletter = $letters[$i + 1]; $i = sizeof($letters); } } $colorstring[sizeof($colorstring)] = $newletter; } $colorstrings[$color] = $colorstring; echo $colorstring."{color:".$color."}\n"; } } ?> --> </style> </head><body bgcolor="<?=$def_color?>"> <P><A HREF="<?=$PHP_SELF?>s">source code</A> <h2>Graphics:<BR></h2><p> <? echo '<h3>'; foreach($img as $name=>$url) { $current_link = $image=="http://$url" ? True : False; echo "<li>"; echo $image=="http://$url" ? $name : "<a href=\"$PHP_SELF?image=$url\">$name</a>"; echo "&nbsp; &nbsp; &nbsp; &nbsp; Zoom by &nbsp;"; for($z=1; $z<=$max_zoom; $z++) { $z_out = ($z*100).'%'; echo (($z==$zoom and $current_link) ? $z_out : "<a href=\"$PHP_SELF?image=$url&zoom=$z\">$z_out</a>").' &nbsp; '; } } echo '</h3>'; if($image=='') Exit; echo '<p>Original / "HTMLazied" '.(($zoom>1)?" (zoomed by $zoom times)":'').'....'; echo "<p><img src=\"$image\">"; echo "<p>&nbsp;"; echo "\n\n\n<pre>"; $str = str_repeat('.', $zoom); $rep = 0; $im = ImageCreateFromPNG($image); $imagesy = imagesy($im); $imagesx = imagesx($im); for($y = 0; $y < $imagesy; $y++) { for($z = 0; $z < $zoom; $z++) { for($x = 0; $x <= $imagesx; $x++) { $color = ImageColorsForIndex($im, ImageColorAt($im, $x, $y)); $rgb = sprintf("%02x%02x%02x",$color['red'],$color['green'],$color['blue']); if($rgb == $def_color) { echo $str; Continue; } if($x>0) { if($tmp_rgb != $rgb or $x == $imagesx) { if($imagecolors[$tmp_rgb] > 1) $line = "<b class=".$imagestrings[$tmp_rgb].">".str_repeat($str, $rep+1)."</b>"; else $line = "<font color=\"$tmp_rgb\">".str_repeat($str, $rep+1)."</font>"; $content .= $line; echo $line; flush; $rep = 0; } else $rep++; } $tmp_rgb = $rgb; } echo "\n"; } #if($y>49) Break; // for testing $tmp_rgb = ''; } echo "\n\n</pre>"; $pixels = $imagesx*$imagesy; $lenth = strlen($content); $extra = $lenth-$pixels; echo " <br>Pixels in Total: <B>$pixels</B> pixels ({$imagesx}x$imagesy) <br>Total Image Size: <B>$lenth</B> bytes <br>Extra HTML: <B>$extra</B> bytes "; ?> <h2>Yup, how's that?</h2> <p>Started by <a href="mailto:sjdtmv@tpg.com.au">ReDucTor</a> Remade by <A HREF="mailto:maxim@maxim.cx">Maxim Maletsky</A> then edited by <a href="mailto:sjdtmv@tpg.com.au">ReDucTor</a> </body></html> - James "ReDucTor" Mitchell ----- Original Message ----- From: "Maxim Maletsky (PHPBeginner.com)" <php-general@phpbeginner.com> To: "'ReDucTor'" <sjdtmv@tpg.com.au>; "'JSheble'" <JustForMailingLists@wizaerd.com>; "'General PHP List'" <php-general@lists.php.net> Sent: Sunday, September 30, 2001 2:44 AM Subject: RE: [PHP] The Histor of The Kewl Script > > No, I though of it. The maximum amount of colors are 255, I could even > use a single char to define them, but will be constricted using them 2 > (common, browser want understand a chr(13) and so). So 4 bytes off. > Another wonderful thing is that I might not have to closing the tags if > using CSS. It shows up like it is working here. > > This should deduct about 20-50% from the HTML load. And the next step > will be merging verticals. > > The only downline is now that a simple 100x100 graphic is at least > 10.000 loops. More you loop more you wait for the damn page to load. > > But the technology behind on the server can always be improved - GIANT > AMOUNT OF HTML needs to be reduced NOW. > > I will have something to show you within a few hours > > Maxim Maletsky > www.PHPBeginner.com > > > > > -----Original Message----- > From: ReDucTor [mailto:sjdtmv@tpg.com.au] > Sent: domenica 29 luglio 2001 18.31 > To: Maxim Maletsky (PHPBeginner.com); 'JSheble'; 'General PHP List' > Subject: Re: [PHP] The Histor of The Kewl Script > > > So the best way is using CSS if there is more then one occerence, but > with your method, you see if its only to bytes for the name of the > class, that limits it to only a certain amount of colors, but as that > expands to length of the class name, it might turn out to be longer, and > quicker to use the font tag...making a script to handle and calculate > all of this, is going to be fun....but you must also keep in mind that > if it gets to much of a load its going to start effecting the server, > but that will take a bit...its mainly i/o that will slow down anything, > so making the size of the output small is going to improve it, unless > the script its self gets to a few mb, but that will take a bit, i don't > know why i am saying this because the likly hood of changing a script > like this into a few mb is very rare....hehe > > - James "ReDucTor" Mitchell > ----- Original Message ----- > From: "Maxim Maletsky (PHPBeginner.com)" <php-general@phpbeginner.com> > To: "'ReDucTor'" <sjdtmv@tpg.com.au>; "'JSheble'" > <JustForMailingLists@wizaerd.com>; "'General PHP List'" > <php-general@lists.php.net> > Sent: Sunday, September 30, 2001 1:55 AM > Subject: RE: [PHP] The Histor of The Kewl Script > > > > > > I think I resolved the problem. > > Apparently there's a chance of compressing the whole graphic way > > deeper by combining HTML with CSS right inside the image HTML itself. > > > > In this invention I declare a class for color that repeats more then x > > > amount of times, then refer to it in this way "<b class>". > > > > The formula is quite long, but looks like will work. It is also safe > > because PHP will calculate if it makes any since to change <font> into > > > <class> basing on the amount of occurrences. > > > > Some of my formulas: > > > > **** > > > > .ab{color:000000} = 18 bytes > > <b class=ab> = 13 bytes > > <FONT COLOR=000000></FONT> = 26 bytes > > > > Assuming the colored graphic 100px*100px; > > Total pixels = 10.000 > > > > when up to 38 unique colors > > CSS Definition = 17 bytes > > CSS Tag = 12 bytes > > > > > > Minimum sequent occurence = 2 > > formula: CSS/HTML (17+12*2)=41 << > > (26*2)=52 > > It is a gain of at least 14 bytes per tag. > > > > > > Assuming 1.000 tags with max. occ. > > maximum size 12*1.000+17*38+10.000 = 22.646 (instead of > > 36.000) > > Saved 14.000k (37%) > > > > Assuming 2.000 tags with max. occ. > > maximum size 12*2.000+17*38+10.000 = 34.646 (instead of > > 62.000) > > Saved 28.000k (44%) > > > > Assuming 5.000 tags with max. occ. (LIMIT) > > maximum size 12*5.000+17*38+10.000 = 70.646 (instead of > > 140.000) > > Saved 70.000k (50%) > > > > > > > > > > when up to 1444 unique colors > > CSS Definition = 18 bytes > > CSS Tag = 13 bytes > > > > Minimum sequent occurence = 2 > > formula: CSS/HTML (18+13*2)=44 << > > (26*2)=52 > > > > It is a gain of at least 13 bytes per tag. > > > > Assuming 5.000 tags with max. occ. (LIMIT) > > maximum size 13*5.000+(18*1440)+10.000 = 101.646 > > (instead of 140.000) > > Saved 70.000k (28%) > > > > > > Multipliying Tag occurances we arrive to much results. > > The examples here are the minums. (and favored to HTML solution) > > > > Another thing is the fact that the style shits will be only created > > for those repeating ones, starting from a single 26 > > > > **** > > > > Will see if browser won't crash. It might though. > > > > Maxim Maletsky > > www.PHPBeginner.com > > > > > > > > -----Original Message----- > > From: ReDucTor [mailto:sjdtmv@tpg.com.au] > > Sent: domenica 29 luglio 2001 14.02 > > To: Maxim Maletsky (PHPBeginner.com); 'JSheble'; 'General PHP List' > > Subject: Re: [PHP] The Histor of The Kewl Script > > > > > > I just found one, as i posted this(my domain php-webmaster.com), i > > just found out its hosted on one with GD Version between 1.3 and > > 1.6.1, but so far i am trying it, and its just not displaying any > > actully text, so, but it reachs the end, because it shows </body> and > > </html>....wierd... > > ----- Original Message ----- > > From: "Maxim Maletsky (PHPBeginner.com)" <php-general@phpbeginner.com> > > To: "'ReDucTor'" <sjdtmv@tpg.com.au>; > > "'JSheble'" > > <JustForMailingLists@wizaerd.com>; "'General PHP List'" > > <php-general@lists.php.net> > > Sent: Saturday, September 29, 2001 9:59 PM > > Subject: RE: [PHP] The Histor of The Kewl Script > > > > > > > We will have one very soon. Give me an hour or so and you'll have > > > access to it :-) > > > > > > > > > Maxim Maletsky > > > www.PHPBeginner.com > > > > > > > > > -----Original Message----- > > > From: ReDucTor [mailto:sjdtmv@tpg.com.au] > > > Sent: domenica 29 luglio 2001 13.37 > > > To: Maxim Maletsky (PHPBeginner.com); 'JSheble'; 'General PHP > > > List' > > > Subject: Re: [PHP] The Histor of The Kewl Script > > > > > > > > > Yep, I started it :D I think its cool, thats lots of people are > > > playing around with it now, its turning out alot better then what i > > > expected... > > > > > > I still havn't got it up a server i can play with, hehe, if anyone > > > knows a free host, that has GD support, and isn't windows, because > > > windows machines crash with ImageColorAt, and well thats one of the > > > main functions of the script, well with out it there wouldn't be a > > > script, and i don't feel like going and finding out how a .png, or a > > > > .jpg image format is, to make something with fopen(), fread(), etc > > > > > > I did some changes and made it only add the font tag if that color > > > wasn't the previous color :D(i posted it agian, somewhere) > > > > > > - James "ReDuCTor" Mitchell > > > > > > > > > ----- Original Message ----- > > > From: "Maxim Maletsky (PHPBeginner.com)" > > > <php-general@phpbeginner.com> > > > To: "'JSheble'" <JustForMailingLists@wizaerd.com>; > > > "'General PHP > > > List'" <php-general@lists.php.net> > > > Sent: Saturday, September 29, 2001 9:28 PM > > > Subject: RE: [PHP] The Histor of The Kewl Script > > > > > > > > > > See, the problem now is not in the page load as of PHP side. Yeah, > > > > > it takes a ces or so... The real problem are those funny 400k > > > > page! > > > > > > > > :-) > > > > > > > > Maxim Maletsky > > > > www.PHPBeginner.com > > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > From: JSheble [mailto:JustForMailingLists@wizaerd.com] > > > > Sent: sabato 29 settembre 2001 7.17 > > > > To: General PHP List > > > > Subject: RE: [PHP] The Histor of The Kewl Script > > > > > > > > > > > > I have a copy of a class written my Markus Dobel called HTMLImage > > > > that > > > > > > > does this same thing, but with one subtle difference. It reads in > > > > > a > > > > > > text file, using the letters and/or words contained within it to > > > > display the image. It can use GIF (if the version of GD supports > > > > GIF files), a JPG or a PNG. Here are two examples, the first a > > > > PNG and the second a JPG. > > > > > > > > > > > > http://www.wizaerdsrealm.com/testscripts/index.php > > > > > > > > and here is the source > > > > > > > > > > > > http://www.wizaerdsrealm.com/testscripts/index.phps > > > > > > > > I downloaded this a while ago because I thought it was pretty > > > > cool... and fairly fast as well... > > > > > > > > Joseph E. Sheble > > > > a.k.a. Wizaerd > > > > Wizaerd's Realm > > > > Canvas, 3D, Graphics, > > > > PHP/mySQL & ColdFusion/MSSQL > > > > http://www.wizaerd.com > > > > ================================= > > > > The Canvas Expert Online > > > > The #1 Resource For Canvas Information > > > > http://www.TheCanvasExpert.com > > > > ================================= > > > > > > > > > -----Original Message----- > > > > > From: ReDucTor [mailto:sjdtmv@tpg.com.au] > > > > > Sent: Friday, September 28, 2001 9:37 PM > > > > > To: Matt Greer; php-general@lists.php.net > > > > > Subject: Re: [PHP] The Histor of The Kewl Script > > > > > > > > > > > > > > > Here is the original, in color, you will have to add $im in the > > > > > first arg, and move the ImageColorAt to the second arg...hehehe, > > > > > > Btw > > > > > > > > it doesn't work on Windows Machines, Which is the original > > > > > reason it > > > > > > > > was posted here.... > > > > > > > > > > But now its advaned, everyones trying to modify it, and getting > > > > > very > > > > > > > > nice effects.... > > > > > > > > > > I got the idea from a c++ app i found, that turned images into a > > > > > > html page... > > > > > > > > > > - James "ReDucTor" Mitchell > > > > > ----- Original Message ----- > > > > > From: "Matt Greer" <tortus@rcnchicago.com> > > > > > To: <php-general@lists.php.net> > > > > > Sent: Saturday, September 29, 2001 2:32 PM > > > > > Subject: Re: [PHP] (was:A kewl Script....) LOOK WHAT IT BECAME! > > > > > > > > > > > > > > > > On Friday 28 September 2001 22:58, Maxim Maletsky > > > > > > \(PHPBeginner.com\) > > > > > wrote: > > > > > > > I have only tested it on IE5.5. again, the problem there is > > > > > the browser > > > > > > > that freezes, it is at least 400k page, and zooming it > > > > > becomes countable > > > > > > > in mega bytes. So, that is why browsers get so mad. > > > > > > > > > > > > zoom 100% loaded very nicely in Mozilla for Linux. Looks real > > > > > > good. I > > > > > tried > > > > > > zoom 200% and after a long wait it showed the pic zoomed at > > > > > > about 2000% > > > > > > > > > > > > Who originated this script, at least the version that got > > > > > > started here > > > > > today? > > > > > > I'm going to be making a website and I thought this might be a > > > > > cool effect > > > > > if > > > > > > used lightly in some places. > > > > > > > > > > > > Matt > > > > > > > > > > > > -- > > > > > > PHP General Mailing List (http://www.php.net/) > > > > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > > > > For additional commands, e-mail: > > > > > > php-general-help@lists.php.net To > > > > > > > > > contact the list administrators, e-mail: > > > > > > php-list-admin@lists.php.net > > > > > > > > > > > > > > > > > > > > > -- > > > > > PHP General Mailing List (http://www.php.net/) > > > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > > > For additional commands, e-mail: php-general-help@lists.php.net > > > > > To > > > > > > > contact the list administrators, e-mail: > > > > > php-list-admin@lists.php.net > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > > For additional commands, e-mail: php-general-help@lists.php.net To > > > > > contact the list administrators, e-mail: > > > > php-list-admin@lists.php.net > > > > > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > > For additional commands, e-mail: php-general-help@lists.php.net To > > > > > contact the list administrators, e-mail: > > > > php-list-admin@lists.php.net > > > > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net To > > contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net To > > contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net To > contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#69303) next »