Archive for the ‘PHP’ Category

Preserve GIF transparency after imagecopyresampled

Friday, January 4th, 2008

Ok, seriously give Martin Schmidt some serious accolades on this because this solution is a very rare find and even tougher to figure out on your own. Thanks Martin!

  1.  
  2. //Begin Transparent Color Resize Correction for Gif and 8bit Png, by Martin Schmidt
  3. $destImg = imagecreatetruecolor( $picx, $picy );
  4. $colorcount = imagecolorstotal($logoImg);
  5. imagetruecolortopalette($destImg,true,$colorcount);
  6. imagepalettecopy($destImg,$logoImg);
  7. $transparentcolor = imagecolortransparent($logoImg);
  8. imagefill($destImg,0,0,$transparentcolor);
  9. imagecolortransparent($destImg,$transparentcolor);
  10. //End Transparent Color Resize Correction

Reset a result source in PHP with mysql_data_seek

Tuesday, August 28th, 2007
  1. $result = mysql_query("SELECT names FROM table;");          
  2.  
  3. while($row=mysql_fetch_array($result,MYSQL_ASSOC)) {
  4.  
  5.           //procedure
  6. }
  7.  
  8. mysql_data_seek($result,0); // Reuse your recordset
  9.  
  10. while($row=mysql_fetch_array($result,MYSQL_ASSOC)) {
  11.  
  12.         //procedure
  13.  
  14. }