Welcome, Guest. Please Login or Register.
May 13, 2024, 06:51:18 AM
Home Help Search Log in Register
News: SMF is the next generation in forum software, almost completely re-written from the ground up, make sure you don't fall for cheap imitations that suffer from feature bloat!

YaBB SE Community  |  Development  |  Graphics and Templates  |  [useless] PNG -> HTML converter « previous next »
Pages: [1] Reply Ignore Print
Author Topic: [useless] PNG -> HTML converter  (Read 3143 times)
Zef Hemel
Advisor
YaBB God
*****
Posts: 1182


Me too

ICQ - 61109769 WWW
[useless] PNG -> HTML converter
« on: January 14, 2002, 05:42:16 PM »
Reply with quote

There, have fun: http://www.fmf.nl/~zef/img2text.php ;D
Logged

Peter Duggan
Llama Chameleon
Global Moderator
YaBB God
*****
Posts: 1793


You come and go...

WWW
Re:[useless] PNG -> HTML converter
« Reply #1 on: January 14, 2002, 05:49:31 PM »
Reply with quote

So it doesn't do transparency? ;)
Logged

Zef Hemel
Advisor
YaBB God
*****
Posts: 1182


Me too

ICQ - 61109769 WWW
Re:[useless] PNG -> HTML converter
« Reply #2 on: January 14, 2002, 05:51:54 PM »
Reply with quote

I don't know, it's something I found somewhere and modified it a bit :P
Logged

Godai
Mod God :P
Sr. Member
****
Posts: 473


YaBB SE!!!!

ICQ - 70621553godai78@hotmail.com WWW
Re:[useless] PNG -> HTML converter
« Reply #3 on: January 14, 2002, 09:53:37 PM »
Reply with quote

It works great :D
Logged

Emanuele 'Godai' Sparvoli
YaBB Italian Team
100% YaBB Lover
andrea
Global Moderator
YaBB God
*****
Posts: 4400


Peace on Earth

WWW
Re:[useless] PNG -> HTML converter
« Reply #4 on: January 15, 2002, 03:09:40 AM »
Reply with quote

Thats great!  :)
Logged

Wiedo
Jr. Member
**
Posts: 50


I love YaBB SE - sure I do baby!

ICQ - 14949685 WWW
Re:[useless] PNG -> HTML converter
« Reply #5 on: January 15, 2002, 11:02:23 AM »
Reply with quote

kan je de code niet veranderen zodat het op het yabb forum postbaar is... ?

(sorry for the dutch talking... I thought I was on Yabb.nl, It meens: Can you modify the code sow you can post it on the yabb forum)
« Last Edit: January 16, 2002, 10:43:11 AM by Kronosz » Logged
Zef Hemel
Advisor
YaBB God
*****
Posts: 1182


Me too

ICQ - 61109769 WWW
Re:[useless] PNG -> HTML converter
« Reply #6 on: January 15, 2002, 11:35:04 AM »
Reply with quote

I can, but you wouldn't be able to post it since it's always to big ;)
Logged

Mostmaster
Full Member
***
Posts: 184


I love all the YaBBs, but this one is the best!

mostmaster@hotmail.com WWW
Re:[useless] PNG -> HTML converter
« Reply #7 on: January 15, 2002, 10:52:47 PM »
Reply with quote

Wow, pretty cool.
Is the source available? I'm always very curious how such things work. I've never worked with images in php before.
« Last Edit: January 15, 2002, 10:53:26 PM by Mostmaster » Logged
Koroco
Jr. Member
**
Posts: 57


I love BBaY ES! (TEAM)

ICQ - 33403904 WWW
Re:[useless] PNG -> HTML converter
« Reply #8 on: January 16, 2002, 01:22:06 AM »
Reply with quote

HEH i want a copy of that script ! :)
Logged

~Koroco
Yes im also very Yabb SExy
http://www.fenixmag.com
Wiedo
Jr. Member
**
Posts: 50


I love YaBB SE - sure I do baby!

ICQ - 14949685 WWW
Re:[useless] PNG -> HTML converter
« Reply #9 on: January 16, 2002, 10:44:41 AM »
Reply with quote

http://213.84.117.25/rommel/zero.html

http://213.84.117.25/rommel/zero2.html
Logged
Zef Hemel
Advisor
YaBB God
*****
Posts: 1182


Me too

ICQ - 61109769 WWW
Re:[useless] PNG -> HTML converter
« Reply #10 on: January 16, 2002, 03:56:50 PM »
Reply with quote

Most code is purely gzipping, but oh well :P
<?php
  
/**
   * Checks if user accepts gzipped output, and if zo compresses the output
   * @param $text text to compress
   * @param $level compression level (1 is recommended)
   */
  
function gzip($text$level=1)
  {
    global 
$TS$DB;
    global 
$HTTP_ACCEPT_ENCODING;

    
// Check if zlib is installed
    
if(function_exists("crc32") && function_exists("gzcompress"))
    {
      
// if so check what kind of gzipping can be used
      
if(strpos(" ".$HTTP_ACCEPT_ENCODING"x-gzip"))
         
$encoding "x-gzip";
      elseif(
strpos(" ".$HTTP_ACCEPT_ENCODING,"gzip"))
         
$encoding "gzip";

      if (
$encoding// ok, encoding is accepted
      
{
         
header("Content-Encoding: $encoding");

         
$size strlen($text);
         
$crc crc32($text);

         
$output "\x1f\x8b\x08\x00\x00\x00\x00\x00";
         
$output .= substr(gzcompress($text$level), 0, -4);
         
$output .= pack("V"$crc);
         
$output .= pack("V"$size);
      }
      else
         
$output $text;
    }
    else
      
$output $text;

    echo 
$output;
  }

ob_start();

if(!
$url)
   
$img "andrea2.png";
else
{
   
$rf fopen($url"rb") or die("Could not open file $url");
   
$buffer "";
   while(
$buf fread($rf1024))
      
$buffer .= $buf;
   
fclose($rf);
   
$fd fopen("image.png""wb") or die("Could not open image.png for writing");
   
fwrite($fd$buffer);
   
fclose($fd);
   
$img "image.png";
}
$imgHand ImageCreateFromPng($img); 

$imgSize GetImageSize($img); 
$imgWidth $imgSize[0]; 
$imgHeight $imgSize[1]; 
$htmlCode "<font style=\"font-size:6pt;\" face=\"Courier\">"
for (
$l 0$l $imgHeight$l++) { 
    
$htmlCode .= "<br>\n"
    for (
$c 0$c $imgWidth$c++) { 
        
$pxlCor ImageColorAt($imgHand,$c,$l); 
        
$pxlCorArr ImageColorsForIndex($imgHand$pxlCor); 
        
$htmlCor DecHex($pxlCorArr["red"]) . DecHex($pxlCorArr["green"]) . DecHex($pxlCorArr["blue"]); 
        
$htmlCode .= "<font color=\"#$htmlCor\">#</font>"
    } 

$htmlCode .= "</font>"
print <<<EOT
<html>
<head>
   <title>PNG 2 ASCII: 
$img</title>
</head>
<body bgcolor="#000000">
<form method="GET">
<font color="#FFFFFF"><b>URL:</b> <input type=text name="url" value="http://www.fmf.nl/~zef/andrea2.png"> (PNG images only!)</font><br>
<input type=submit value="View">
</form>
EOT;
print 
$htmlCode
print 
"</body></html>";

$html ob_get_contents();
ob_end_clean();
gzip($html1);
exit();
?>

Logged

Koroco
Jr. Member
**
Posts: 57


I love BBaY ES! (TEAM)

ICQ - 33403904 WWW
Re:[useless] PNG -> HTML converter
« Reply #11 on: January 17, 2002, 02:28:04 AM »
Reply with quote

LOL i think mine is fricked up
i get this error on EVERYLINE in my php source:
Warning: Supplied argument is not a valid Image resource in [path]

(im not giving out my path :P)
Logged

~Koroco
Yes im also very Yabb SExy
http://www.fenixmag.com
Koroco
Jr. Member
**
Posts: 57


I love BBaY ES! (TEAM)

ICQ - 33403904 WWW
Re:[useless] PNG -> HTML converter
« Reply #12 on: January 17, 2002, 02:33:17 AM »
Reply with quote

well actually it says theres lots of errors on lines 67 and 68, i think thats where the < font> out puts and the </font>
hehehe damn !!!!

hmm i bet i dont have gzipping on my server  :'(
« Last Edit: January 17, 2002, 02:38:08 AM by Koroco » Logged

~Koroco
Yes im also very Yabb SExy
http://www.fenixmag.com
Koroco
Jr. Member
**
Posts: 57


I love BBaY ES! (TEAM)

ICQ - 33403904 WWW
Re:[useless] PNG -> HTML converter
« Reply #13 on: January 20, 2002, 07:24:49 PM »
Reply with quote

Zef You should make that Yabb Compatible so u can do it in the forums, make another php file:
<?php
  
/**
  * Checks if user accepts gzipped output, and if zo compresses the output
  * @param $text text to compress
  * @param $level compression level (1 is recommended)
  */
  
function gzip($text$level=1)
  {
    global 
$TS$DB;
    global 
$HTTP_ACCEPT_ENCODING;

    
// Check if zlib is installed
    
if(function_exists("crc32") && function_exists("gzcompress"))
    {
      
// if so check what kind of gzipping can be used
      
if(strpos(" ".$HTTP_ACCEPT_ENCODING"x-gzip"))
        
$encoding "x-gzip";
      elseif(
strpos(" ".$HTTP_ACCEPT_ENCODING,"gzip"))
        
$encoding "gzip";

      if (
$encoding// ok, encoding is accepted
      
{
        
header("Content-Encoding: $encoding");

        
$size strlen($text);
        
$crc crc32($text);

        
$output "\x1f\x8b\x08\x00\x00\x00\x00\x00";
        
$output .= substr(gzcompress($text$level), 0, -4);
        
$output .= pack("V"$crc);
        
$output .= pack("V"$size);
      }
      else
         
$output $text;
    }
    else
      
$output $text;

    echo 
$output;
  }

ob_start();

if(!
$url)
   
$img "andrea2.png";
else
{
   
$rf fopen($url"rb") or die("Could not open file $url");
   
$buffer "";
   while(
$buf fread($rf1024))
      
$buffer .= $buf;
   
fclose($rf);
   
$fd fopen("image.png""wb") or die("Could not open image.png for writing");
   
fwrite($fd$buffer);
   
fclose($fd);
   
$img "image.png";
}
$imgHand ImageCreateFromPng($img); 

$imgSize GetImageSize($img); 
$imgWidth $imgSize[0]; 
$imgHeight $imgSize[1]; 
$htmlCode "[font=Courier]"
for (
$l 0$l $imgHeight$l++) { 
    
$htmlCode .= "<br>\n"
    for (
$c 0$c $imgWidth$c++) { 
        
$pxlCor ImageColorAt($imgHand,$c,$l); 
        
$pxlCorArr ImageColorsForIndex($imgHand$pxlCor); 
        
$htmlCor DecHex($pxlCorArr["red"]) . DecHex($pxlCorArr["green"]) . DecHex($pxlCorArr["blue"]); 
        
$htmlCode .= "[color=#$htmlCor]#[/color]"
    } 

$htmlCode .= "[/font]"
print <<<EOT
<html>
<head>
   <title>PNG 2 ASCII: 
$img</title>
</head>
<body bgcolor="#000000">
<form method="GET">
<font color="#FFFFFF"><b>URL:</b> <input type=text name="url" value="http://www.fmf.nl/~zef/andrea2.png"> (PNG images only!)</font><br>
<input type=submit value="View">
</form>
EOT;
print 
$htmlCode
print 
"</body></html>";

$html ob_get_contents();
ob_end_clean();
gzip($html1);
exit();
?>

« Last Edit: January 20, 2002, 07:25:42 PM by Koroco » Logged

~Koroco
Yes im also very Yabb SExy
http://www.fenixmag.com
Zef Hemel
Advisor
YaBB God
*****
Posts: 1182


Me too

ICQ - 61109769 WWW
Re:[useless] PNG -> HTML converter
« Reply #14 on: January 21, 2002, 03:50:47 PM »
Reply with quote

I could, but every message the script would be generate would exceed the message limit so it's no use :)
Logged

Pages: [1] Reply Ignore Print 
YaBB SE Community  |  Development  |  Graphics and Templates  |  [useless] PNG -> HTML converter « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.318 seconds with 20 queries.