Advertisement
Guest User

NFG

a guest
Jun 22nd, 2009
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.87 KB | None | 0 0
  1. <?
  2.  
  3.                 // This is the PHP script of DOOM
  4.                 // It prolly won't work.
  5.  
  6.                 // Written by NFG ( http://nfgworld.com ) in February 2009.
  7.  
  8.                 // While I take credit for making the thing assemble fonts
  9.                 // Which I'm mad proud of, 'cause I don't code...
  10.                 // Many kudos to Twyst for helping with some tricky stuff:
  11.                 //      PHPBB URLs
  12.                 //      maintenance-friendly filenames.
  13.                 //      colour shifting
  14.  
  15.  
  16. /* ------------------------------------------------ */
  17. /*                      License                     */
  18. /* ------------------------------------------------ */
  19.  
  20. /*              This script is released under a Creative Commons Zero license.
  21.                 This means it's free of just about all encumbrances.
  22.                 Do what you want with it.
  23.                 A tip of the hat for ol' NFG would be nice, but not required.  =)
  24.                
  25.                 http://creativecommons.org/licenses/zero/1.0/
  26.  
  27. /* ------------------------------------------------ */
  28. /*                  Version History                 */
  29. /* ------------------------------------------------ */
  30. /*
  31.         1.0 - First Public Release
  32.         1.1 - Added Font List & Font Counter, fixed some bugs that only became apparent with the lister...
  33.               Includes word-balloon addition by Twystneko.
  34.         1.2 - Added random font option.  This required some internal changes, but no functional differences.
  35.         1.3 - Added default string values in cases where X, Y or Z values are not set.
  36.             - Added handler for LARGE FONTS.  Fonts that are not 8x8 should go in a directory    largefonts/
  37.  
  38. /* ------------------------------------------------ */
  39. /*              Instructional Block                 */
  40. /* ------------------------------------------------ */
  41.  
  42. /*  HOW TO USE THIS SCRIPT
  43.         1. Requirements
  44.                 PHP
  45.                 GD graphics library (almost always included with PHP)
  46.                 A website (duh)
  47.                 This script (also duh)
  48.                 Some fonts (slightly less, but still duh)
  49.  
  50.         2. Usage
  51.                 . First, decide if you'll use PHPBB-friendly parameters or not.  
  52.           I suggest leaving this on by default, and just get used to the way it works.
  53.                 . The output of this script is a .PNG image.
  54.                   To link to it, or use it in a webpage, just put the script URL and
  55.                   parameters between some [img] or <img> tags.  It's not tricky.
  56.  
  57.            Examples
  58.                 . Webpage: <img src="http://server/path-to-script/arcade.php/y-font/x-phrase to encode" />
  59.                 . Forum: [img]http://server/path-to-script/arcade.php/y-font/x-phrase to encode[/img]
  60.  
  61.         3. Things to watch for
  62.                 . Some forums don't like spaces in the names.  Use the HTML-friendly space:   %20    instead.  so,   /x-phrase%20to%20encode
  63.                 . Many parameters are optional.  The minimum is font (y) and phrase (x).  
  64.  
  65.         4. Parameters
  66.                 x - words or phrase to create image with
  67.                 y - font to use.  Use r for random (usage:  /y-r/ )
  68.                 z - colour or variation.  A font file may contain several fonts stacked vertically.  
  69.                     This chooses how many rows down an image file to start. (starts at zero!)
  70.                     use r for random (usage: /z-r/ )
  71.                 h - height of character (default is 8 if unset)
  72.                 w - width of character (default is 8 if unset)
  73.                     Note that all characters must be the same height and width.  
  74.                     There is no facility for variable width fonts.
  75.                 dbl - doublesize or not.  If un-set, defaults to 1x, but you can set dbl to 2-6.  
  76.                     The script will reduce all values larger than six to six.
  77.                     4x example:  /dbl-4    
  78.                 cs - colour shift, to adjust the hue of the font.  
  79.                     Format is red.green.blue.  
  80.                     Example:  /cs-0.128.64
  81.                 list - list all fonts.  Ignores the x-phrase and y-fontchoice, but obeys all other commands.  (usage:  /list-1/ )
  82.                 count - changes x-phrase into the number of available fonts.  Obeys all other commands.   (usage: /count-1/ )
  83.                 b - Bubble position. This activates the speech bubble mode, and is either "u" (up) or "d" (down).
  84.                 bp - a percentage of where it is along the bubble.
  85.  
  86.     5. Filenames
  87.         Your filenames MUST be in this format:  shortcut-whateveryouwant.png
  88.                 where:      shortcut        is the Y/Fontchoice value used in the URL.
  89.         where:      whateveryouwant     is the descriptive name of the font.
  90.                 example:    fz-FantasyZone.png      the Y/URL code for this font is fz.
  91.                 example:    cotn-Cotton.png     the Y/URL code for this one is cotn.
  92.                 usage:      arcade.php?y=cotn&x=This is the Cotton font!
  93.  
  94. */
  95.  
  96. /* ------------------------------------------------ */
  97. /*              Configuration Block                 */
  98. /*         Edit these settings as desired           */
  99. /* ------------------------------------------------ */
  100.  
  101.                 // NOTE: Config options: 1 = YES, 0 = NO
  102.  
  103.                 // Many forums, including the popular phpBB, won't allow images with ?, = or & in the path.
  104.                 // Do you want standard URLs    arcade.php?param=value&param2=value2
  105.                 // Or PHPbb-friendly URLs?              arcade.php/param-value/param2-value2/.png
  106. $phpbbfriendly = 1;
  107.  
  108.                 // Cache previously-created images?
  109.         // Note that on a Windows system, there's no filename difference between upper and lower case, so
  110.         // cached phrases will no refresh if you change the capitalization later.
  111.         // For example, Windows thinks phrase.png is the same as Phrase.png and PHRASE.png and PhRaSe.png
  112. $cacheornot = 1;
  113.  
  114.                 // Directory to store cached images:
  115.                 // Should prolly be something like   ./cache/  for most servers.  
  116.                 // Be sure to create this directory!  
  117.                 // And make it writable!!
  118. $filepath = './cache/';
  119.  
  120.                 // Set the directory where you store the source fontfiles.  Should be ./fonts/ for most servers.
  121.                 // If you have any fonts larger than 8x8 you should put them in a different directory.
  122.                 //      (sadly this is more for my benefit than yours)
  123. $dir = './fonts/';
  124. $bigdir = './largefonts/';
  125.  
  126.                 // where the components for the speech bubbles are
  127. $bubblepath = "./bubble/";
  128.  
  129.                 // I suspect you'll want to stick to 8x8 characters, but if you get something bigger, specify the size here.
  130.                 // Note: this can be overridden later with the H and V parameters.  This just sets the default.
  131.                 // Set default source character width in pixels
  132. $charwidth = 8;
  133.                 // Set default source character height in pixels
  134. $charheight = 8;
  135.  
  136.                 // Character offset: It skips the first 32 ASCII chars, 'cause they're all control-characters that you'll never use.
  137.                 // You should never need to change this.
  138. $charoffset = 32;
  139.  
  140.                 // Set the maximum phrase length (default 100 chars:
  141. $stringlimit = 100;
  142.  
  143.                 // Allow the creation of a long list of available fonts?
  144.                 // When doing a font list, the spacing between fonts is 1 x fontsize, so 3x font = 3px gap.
  145. $allowlist = 1;
  146.  
  147. /* ------------------------------------------------ */
  148. /*    Set up default values to keep things from     */
  149. /*     from breaking when no values are in URL      */
  150. /* ------------------------------------------------ */
  151.  
  152. $fontchoice = "taitoa";
  153. $randomfontcolour = FALSE;
  154.  
  155. /* ------------------------------------------------ */
  156. /*    You shouldn't need to muck about past here    */
  157. /*           Commented for your enjoy!              */
  158. /*                                                  */
  159. /*     First, get the vars from the URL request     */
  160. /* ------------------------------------------------ */
  161.  
  162. if ($phpbbfriendly == 1) {                                                                                                              
  163.             // This is the PHPbb-friendly version
  164.                 $scriptname = $_SERVER['SCRIPT_NAME']."/";
  165.                 $filename = str_replace($scriptname, '', $_SERVER['REQUEST_URI']);
  166.                 $filename = urldecode($filename);
  167.                 $bits = explode("/",$filename);
  168.                 $out = array();
  169.                 foreach($bits as $bite) {
  170.                                 $temp = explode("-",$bite, 2);
  171.                                 $out[$temp[0]] = $temp[1];
  172.                 }
  173.                                 // String to create:
  174.                 if ($out["x"]) {
  175.                     $string = $out["x"];
  176.                 } else {
  177.                     $string = "NULL";
  178.                 }
  179.                                 // Get the desired font file:
  180.                 if ($out["y"]) {
  181.                     if ($out["y"] == "r") {
  182.                         $randomfont = TRUE;
  183.                     } else {
  184.                         $fontchoice = $out["y"];
  185.                     }
  186.                 } else {
  187.                     $fontchoice = "taitoa";
  188.                 }
  189.                                 // Row offset (font colour in multiple-colour fonts)
  190.                 if ($out["z"]) {
  191.                         if ($out["z"] == "r") {
  192.                             $randomfontcolour = TRUE;
  193.                         } else {
  194.                             $randomfontcolour = FALSE;
  195.                             $charcolor = $out["z"];
  196.                         }
  197.                 } else {
  198.                     $charcolor = "0";
  199.                 }
  200.  
  201.                                 // Check dbl: if set, it becomes the multiplier (up to 6x)
  202.                 if ($out["dbl"]) {
  203.                         $doublesize = $out["dbl"];
  204.                                 // There's no point setting the multiplier to ONE, so if set, change it to TWO
  205.                         if ( $doublesize <= 1 ) {
  206.                                 $doublesize = 2;
  207.                         }
  208.                 }      
  209.                                 // Check for height/width overrides.  
  210.                                 //      If H or V parameters exist, change the font size.
  211.                                 //      Also, change font directory to $bigdir (defined above)
  212.                 if ($out["w"]) {
  213.                         $charwidth = $out["w"];
  214.                         $dir = $bigdir;
  215.                 }
  216.                 if ($out["h"]) {
  217.                         $charheight = $out["h"];
  218.                         $dir = $bigdir;
  219.                 }
  220.                 if ($out["cs"]) {
  221.                         $colorize = explode(".",$out["cs"]);
  222.                 }
  223.                 if($out["b"]) {
  224.                     $b = $out['b'];
  225.                 }
  226.                 if($out["bp"]) {
  227.                     $bp = $out['bp'];
  228.                 } else {
  229.                     $bp = 0;
  230.                 }
  231.                 if ($out["list"]) {
  232.                         $listfonts = true;
  233.                 } else {
  234.                         $listfonts = false;
  235.                 }
  236.                 if ($out["count"]) {
  237.                         $countfonts = true;
  238.                 } else {
  239.                         $countfonts = false;
  240.                 }
  241.  
  242. } else {                                                                                                                                                
  243.             // This is the normal version, using standard URL parameters
  244.                 // String to create:
  245.                 if ($_GET["x"]) {
  246.                     $string = $_GET["x"];  
  247.                 } else {
  248.                     $string = "NULL";
  249.                 }
  250.                                 // Get the desired font file:
  251.                 if ($_GET["y"]) {
  252.                     if ($_GET["y"] == "r") {
  253.                         $randomfont = TRUE;
  254.                     } else {
  255.                         $fontchoice = $_GET["y"];
  256.                     }
  257.                 } else {
  258.                     $fontchoice = "taitoa";
  259.                 }
  260.                                 // Vertical offset (font colour in multiple-colour fonts)
  261.                 if ($_GET["z"]) {
  262.                         if ($_GET["z"] == "r") {
  263.                             $randomfontcolour = TRUE;
  264.                         } else {
  265.                             $randomfontcolour = FALSE;
  266.                             $charcolor = $out["z"];
  267.                         }
  268.                 } else {
  269.                     $charcolor = "1";
  270.                 }
  271.                                 // Check dbl: if set, it becomes the multiplier (up to 6x)
  272.                 if ($_GET["dbl"]) {
  273.                         $doublesize = $_GET["dbl"];
  274.                                         // There's no point setting the multiplier to ONE, so if set, change it to TWO
  275.                         if ( $doublesize <= 1 ) {
  276.                                 $doublesize = 2;
  277.                         }
  278.                 }
  279.                                         // Check for height/width overrides.  If H or V parameters exist, change the font size.
  280.                 if ($_GET["w"]) {
  281.                         $charwidth = $_GET["w"];
  282.                         $dir = $bigdir;
  283.                 }
  284.                 if ($_GET["h"]) {
  285.                         $charheight = $_GET["h"];
  286.                         $dir = $bigdir;
  287.                 }
  288.                 if ($_GET["cs"]) {
  289.                         $colorize = explode(".",$_GET["cs"]);
  290.                 }
  291.                 if($_GET["b"]) {
  292.                         $b = $_GET['b'];
  293.                 }
  294.                 if($_GET["bp"]) {
  295.                         $bp = $_GET['bp'];
  296.                 } else {
  297.                     $bp = 0;
  298.                 }
  299.                 if ($_GET["list"]) {
  300.                         $listfonts = true;
  301.                 } else {
  302.                         $listfonts = false;
  303.                 }
  304.                 if ($_GET["count"]) {
  305.                         $countfonts = true;
  306.                 } else {
  307.                         $countfonts = false;
  308.                 }                
  309. }
  310.  if($b == "none") {
  311.     unset($b);
  312.  }
  313.  
  314.                 // We don't need any fonts larger than 6x, do we?
  315. if ($doublesize > 6) {
  316.         $doublesize = 6;
  317. }
  318.  
  319. /* ------------------------------------------------ */
  320. /*         Sanitize the string, for safety!         */
  321. /* ------------------------------------------------ */
  322.  
  323.                 // First, check for chars outside ASCII range 32-126 (20-7E in hex).
  324. $string = preg_replace('/[^(\x20-\x7E)]*/','', $string);
  325.                 // Limit string to the number of chars specified in config:
  326. $string = substr($string, 0, $stringlimit);
  327.  
  328. /* ------------------------------------------------ */
  329. /*   Now, generate a filename and check the cache   */
  330. /* ------------------------------------------------ */
  331.  
  332.                 // Create the filename.  Skip the entire cache procedure if we're listing or counting fonts.
  333. if ((!$listfonts) or (!$countfonts)) {
  334.     $stringpure = urlencode($string);
  335.     $current = "./cache/".$fontchoice.$charcolor.$doublesize.$charheight.$charwidth.$stringpure.".png";
  336.                 // Check the cache.  If the file exists, spit it out and die:
  337.     if (file_exists($current)) {
  338.         $contentType = 'Content-type: image/png';
  339.         header ($contentType);
  340.         readfile($current);
  341.         die;
  342.     }
  343. }
  344.  
  345.  
  346. /* ------------------------------------------------ */
  347. /*     This is the new font Detect and Select!      */
  348. /*   Look for a file which matches the $fontchoice  */
  349. /* ------------------------------------------------ */
  350.  
  351.                 // Thanks Twyst for this segment!
  352.  
  353.                 // Basically opens the $dir specified in the config block
  354.                 // then loops through every file looking for one that matches the Y/Fontchoice value
  355.                 // New in 1.1 - remembers the number of fonts and the max font-name-length for the fontlist
  356.  
  357. $maxfontlength = "0";   // For counting the max chars in a font name (for calc'ing font list width)
  358. $numfonts = "0";        // for counting the number of fonts
  359.  
  360. if ($handle = opendir($dir)) {
  361.         while (false !== ($file = readdir($handle))) {
  362.                 $temp = explode("-",$file,2);
  363.                 if(count($temp) > 1) {                      // means it was split up
  364.                     $fontnames[$numfonts] = $file;          // An array of filenames, for later abuse.
  365.                     $maxfontlength = max($maxfontlength, strlen(substr($temp[1],0,-4)));
  366.                     if ($listfonts) { $fontfiles[$numfonts] = $dir.$file; }
  367.                         if($fontchoice == $temp[0]) {
  368.                             $fontfile = $dir.$file;         // If the current file prefix matches the $fontchoice, specify the SOURCE image
  369.  
  370.                         }
  371.                     $numfonts++;                            // increment the font count.  Also used for incrementing $fontnames array.
  372.                     }
  373.         }
  374. }
  375.  
  376. /* ------------------------------------------------ */
  377. /*             Special-case adjustments             */
  378. /*        For LIST, COUNT and similar things        */
  379. /* ------------------------------------------------ */
  380.  
  381.                 // Are we counting the fonts?  Change the string to the number of fonts.
  382. if ($countfonts) {
  383.         $string = $numfonts;
  384. }
  385.  
  386.                 // If we're doing $randomfonts, change the font filename to be a random one:
  387. if ($randomfont) {
  388.     $fontarraychoice = rand(0,$numfonts);
  389.     $fontfile = $dir.$fontnames[$fontarraychoice];
  390. }
  391.  
  392.                 // Is the font colour random?  Check the z-depth and pick one.
  393. if ($randomfontcolour) {
  394.     $size = getimagesize($fontfile);
  395.     $zcount = $size[1] / $charheight;
  396.     $charcolor = rand(0,$zcount);
  397. }
  398.  
  399. /* ------------------------------------------------ */
  400. /*          This is the preparation section         */
  401. /* ------------------------------------------------ */
  402.  
  403.                 //The new image width should equal the # of chars x the width of each.
  404. if ($listfonts) {
  405.     $newimgwidth = ($charwidth * $maxfontlength);
  406. } else {
  407.     $newimgwidth = ($charwidth * strlen($string));
  408. }
  409.                 //The new image height should equal the # of fonts x the height of each char of each.
  410. if ($listfonts) {
  411.     $newimgheight = (($charheight * $numfonts) + ($numfonts * 2));
  412. } else {
  413.     $newimgheight = $charheight;
  414. }
  415.  
  416.  
  417. /* ------------------------------------------------ */
  418. /*         Start building the new PNG image         */
  419. /* ------------------------------------------------ */
  420.  
  421.  
  422.                 // Create the image (width, height)
  423. $newimg = imagecreatetruecolor($newimgwidth, $newimgheight);
  424.  
  425.                 // Set up the transparent background:
  426. imagealphablending($newimg,false);
  427. $col=imagecolorallocatealpha($newimg,44,0,0,127);
  428. imagefilledrectangle($newimg,0,0,$newimgwidth,$newimgheight,$col);
  429.  
  430. /* ------------------------------------------------ */
  431. /*          Now the character cut/paste loop        */
  432. /* ------------------------------------------------ */
  433.  
  434.  
  435.         //  NEW for v1.1 - loops through the vertical to accomodate the list.
  436.  
  437.         // Begin vertical loop.  Number of fonts determines number of loops.
  438.         // $fontnames is the array
  439.  
  440.                 // If we're counting fonts, echo only the count value, replacing any user string in the URL
  441.  
  442. $vertloop = 0;                      // set vertical loop counter to zero
  443.  
  444. foreach ($fontnames as $currentfont) {
  445.     if ($listfonts) {
  446.         $fontbits = explode("-",$currentfont,2);
  447.         $string = substr($fontbits[1],0,-4);        // If this is a font list, the current string should be the font name
  448.         $currentVpos = (($charheight + 2) * $vertloop);
  449.         $srcimg = imagecreatefrompng($fontfiles[$vertloop]);
  450.     } else {
  451.         $srcimg = imagecreatefrompng($fontfile);    // Change to the current fontfile.
  452.     }
  453.                     echo $fontfiles[$numfonts];
  454.                     // Set horizontal loop char-counter to zero
  455.         $charcount = 0;
  456.                     // Start Loop, repeat for each character in the string:
  457.         foreach(str_split($string) as $char) {
  458.                     // returns ASCII number
  459.             $ASCIIno = ord($char);
  460.                     // Set NEWIMG current cursor H position
  461.             $currentHpos = ($charwidth * $charcount);
  462.                     // H-position for grabbing char from SRC image (width x ASCII number + offset)
  463.             $srcimgcharpos = ($ASCIIno - $charoffset) * $charwidth;
  464.                     // Copy the letter from font image to new image
  465.             imagecopy($newimg, $srcimg, $currentHpos, $currentVpos, $srcimgcharpos, $charcolor * $charheight, $charwidth, $charheight);
  466.                     // Move to next char in string
  467.             $charcount++;
  468.         }
  469.         $vertloop++;                // Increment the vertical counter
  470. }
  471.  
  472. imagesavealpha($newimg,true);
  473.  
  474. /* ------------------------------------------------ */
  475. /*              Colour Shift If Desired             */
  476. /* ------------------------------------------------ */
  477.  
  478.  if($colorize) {
  479.         imagefilter($newimg, IMG_FILTER_COLORIZE, $colorize[0],$colorize[1],$colorize[2]);
  480. }
  481.  
  482. /* ------------------------------------------------ */
  483. /*         Two save-routines: big and x size        */
  484. /* ------------------------------------------------ */
  485.  
  486.                 // Filename is the $string:
  487. $filename = $fontchoice.$charcolor.$doublesize.$charheight.$charwidth.$stringpure.".png";
  488. if($b) {
  489.        
  490.     if($b == "d") {
  491.         // the pointer is down.
  492.         $dir = "bot";
  493.     } else {
  494.         $dir = "top";
  495.     }
  496.     if($bp <= 40) {
  497.         $s = "l";
  498.     } elseif($bp >= 60) {
  499.         $s = "r";
  500.     } else {
  501.         $s = "c";
  502.     }
  503.     $pname = $s."-".$dir.".png";
  504.     $pt = imagecreatefrompng($bubblepath.$pname);
  505.     // got the pointer.
  506.     // now build step 1 - the background
  507.     $bgt = imagecreatefrompng($bubblepath."bg.png");
  508.    
  509.    
  510.     $width = imagesx($newimg);
  511.     $height = imagesy($newimg);
  512.    
  513.    
  514.    
  515.     $step1 = imagecreatetruecolor($width+4, $height+8);
  516.     imagesavealpha($step1,true);
  517.     imagecopyresized($step1, $bgt, 0,0,0,0,$width+4, $height+8,imagesx($bgt),imagesy($bgt));
  518.     imagecopy($step1,$newimg,2,4,0,0,$width,$height);
  519.     $widthb = imagesx($step1);
  520.     $heightb= $height+8;
  521.     $step2 = imagecreatetruecolor($widthb +8, $heightb);
  522.     imagesavealpha($step2,true);
  523.     $bg = imagecolorallocatealpha($step2,255,255,255,127);
  524.     imagefill($step2,0,0,$bg);
  525.     imagecopy($step2,$step1,4,0,0,0,$widthb,$heightb);
  526.     $lft = imagecreatefrompng($bubblepath.'l-end.png');
  527.     $rgt = imagecreatefrompng($bubblepath.'r-end.png');
  528.     imagecopy($step2,$lft,0,0,0,0,4,16);
  529.     imagecopy($step2,$rgt,$widthb+4,0,0,0,4,16);
  530.    
  531.    
  532.     $step3 = imagecreatetruecolor(imagesx($step2), imagesy($step2)+8);
  533.     imagesavealpha($step3,true);
  534.     $bg = imagecolorallocatealpha($step3,255,255,255,127);
  535.     imagefill($step3,0,0,$bg);
  536.     if($b == "u") {
  537.         $voffset = 8;
  538.         $poffset = 0;
  539.     } else {
  540.         $voffset = 0;
  541.         $poffset = imagesy($step2) - 2;
  542.     }
  543.    
  544.     $xpos = floor($width * ($bp/100)) + 4;
  545.     imagecopy($step3,$step2,0,$voffset,0,0,imagesx($step2), imagesy($step2));
  546.     imagecopy($step3,$pt,$xpos,$poffset,0,0,imagesx($pt),imagesy($pt));
  547.     $newimg = $step3;
  548.    
  549. }
  550. if ($doublesize > 1) {
  551.                         // Create NewNewImg
  552.         $newimgwidth = imagesx($newimg);
  553.         $newimgheight = imagesy($newimg);
  554.         $newnewimg = imagecreatetruecolor($newimgwidth*$doublesize, $newimgheight*$doublesize);
  555.  
  556.                         // Set up the transparent background:
  557.         imagealphablending($newnewimg,false);
  558.         $col=imagecolorallocatealpha($newnewimg,44,0,0,127);
  559.         imagefilledrectangle($newnewimg,0,0,$newimgwidth*$doublesize,$charheight * $doublesize,$col);
  560.  
  561.                         // Double the size from old image to new image:
  562.         imagecopyresized($newnewimg, $newimg, 0, 0, 0, 0, $newimgwidth * $doublesize, $newimgheight * $doublesize, $newimgwidth, $newimgheight);
  563.  
  564.         // Output and free from memory:
  565.         header('Content-Type: image/png');
  566.         imagesavealpha($newnewimg,true);
  567.                         // If cache is set to yes, save the file:
  568.         if ($cacheornot == 1) {
  569.                 imagepng($newnewimg, $filepath.$filename);
  570.         }
  571.         imagepng($newnewimg);
  572.         imagedestroy($newimg);
  573.         imagedestroy($newnewimg);
  574.         imagedestroy($srcimg);
  575.  
  576. } else {
  577.  
  578.         // Output and free from memory:
  579.         header('Content-Type: image/png');
  580.         imagepng($newimg);
  581.                                 // If cache is set to yes, save the file:
  582.         if ($cacheornot == 1) {
  583.                 imagepng($newimg, $filepath.$filename);
  584.         }
  585.         imagedestroy($newimg);
  586.         imagedestroy($srcimg);
  587.  
  588. }
  589.  
  590. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement