Created
          December 10, 2008 15:04 
        
      - 
      
- 
        Save mgng/34342 to your computer and use it in GitHub Desktop. 
    gif transparent check
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| // gif transparent check | |
| function getGifTp($imgPath) { | |
| $sz = getimagesize($imgPath); | |
| $x = $sz[0]; | |
| $y = $sz[1]; | |
| $im = imagecreatefromgif($imgPath); | |
| for($sx=0; $sx<$x; $sx++) { | |
| for($sy=0; $sy<$y; $sy++) { | |
| $rgb = imagecolorat($im, $sx, $sy); | |
| $idx = imagecolorsforindex($im, $rgb); | |
| if ($idx['alpha'] !== 0) { | |
| imagedestroy($im); | |
| return $idx; | |
| } | |
| } | |
| } | |
| imagedestroy($im); | |
| return false; | |
| } | |
| var_dump( | |
| getGifTp('transparent.gif'), // array | |
| getGifTp('default.gif') // null | |
| ); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment