Created
July 29, 2015 08:02
-
-
Save gesior/6f5f7d15cb50f59a88fd to your computer and use it in GitHub Desktop.
This file contains 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 | |
$from = 'items'; // images PNG folder | |
$to = 'gif'; // empty folder | |
function png2gif($pngs, $background = array(255, 255, 255), $dest = 'gif') | |
{ | |
// by WebReflection | |
foreach($pngs as $png){ | |
$size = getimagesize($png); | |
$img = imagecreatefrompng($png); | |
$image = imagecreatetruecolor($width = $size[0], $height = $size[1]); | |
imagefill($image, 0, 0, $bgcolor = imagecolorallocate($image, $background[0], $background[1], $background[2])); | |
imagecopyresampled($image, $img, 0, 0, 0, 0, $width, $height, $width, $height); | |
imagecolortransparent($image, $bgcolor); | |
imagegif($image, str_ireplace('.png', '.gif', $dest.DIRECTORY_SEPARATOR.basename($png)), 100); | |
imagedestroy($image); | |
} | |
} | |
png2gif(glob($from . "/*.png"), $background = array(255, 255, 255), $to); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you know, pls help me: Sybio/ImageWorkshop#95