Sybio / ImageWorkshop

ImageWorkshop is a PHP5.3+ library that helps you to manage images based on GD library
http://phpimageworkshop.com/
Other
861 stars 189 forks source link

Black Background of Gif ? help me #95

Open fwcanlam opened 7 years ago

fwcanlam commented 7 years ago

I try to create new gif from gift creator tool, but it has black background. So, how to fix it ? Please help me ! 1

jdecool commented 7 years ago

Hi, could you send the original gif ?

fwcanlam commented 7 years ago

thanks for reply me, @jdecool This is all. they have transparent background. 1 1-2 1 0

jdecool commented 7 years ago

I can't check your problem today.

I will make some tests this weekend.

In addition to your images, can you create a gift with the code you used to generate your image ?

Thanks.

fwcanlam commented 7 years ago

`<?php $rootpath = ''; require('incfiles/core.php'); use PHPImageWorkshop\ImageWorkshop; require_once($phpbb_root_path.'PHPImageWorkshop/ImageWorkshop.php'); class GifCreator { /**

$canh=ImageWorkshop::initFromPath($rootpath.'/learnecom/images/canh/2.png'); $base->addLayerOnTop($canh, 0, 10, "LB");

$canh=ImageWorkshop::initFromPath($rootpath.'/learnecom/equip/quanao/m/5.png'); $base->addLayerOnTop($canh, 0, 0, "LB"); $base2->addLayerOnTop($canh, 0, 0, "LB"); $canh=ImageWorkshop::initFromPath($rootpath.'/learnecom/equip/bieucam/m/3.png'); $base->addLayerOnTop($canh, 0, 0, "LB"); $canh=ImageWorkshop::initFromPath($rootpath.'/learnecom/equip/bieucam/m/3-2.png'); $base2->addLayerOnTop($canh, 0, 0, "LB"); $canh=ImageWorkshop::initFromPath($rootpath.'/learnecom/images/toc/1.png'); $base->addLayerOnTop($canh, 0, 0, "LB"); $base2->addLayerOnTop($canh, 0, 0, "LB");

$canh=ImageWorkshop::initFromPath($rootpath.'/learnecom/images/kinh/7.png'); $base->addLayerOnTop($canh, 0, 0, "LB");

$canh=ImageWorkshop::initFromPath($rootpath.'/learnecom/images/non/25.png'); $base->addLayerOnTop($canh, 0, 0, "LB");

$canh=ImageWorkshop::initFromPath($rootpath.'/learnecom/images/vukhi/2.png'); $base->addLayerOnTop($canh, 0, 0, "LB");

$desiredWidth = 120; $desiredHeight = 150; $image = $base->getResult(); $image2 = $base2->getResult(); $frames = array($image,$image2); $durations = array(150, 50); $gc = new GifCreator(); $gc->create($frames, $durations, 0); $gifBinary = $gc->getGif(); header('Content-type: image/gif'); echo $gifBinary; exit; ?>` This is simple, right ?

fwcanlam commented 7 years ago

This is my result today, But it has an error. I cant fix it. Can you help me ? My code: [code] $image = $base->getResult(); $image2 = $base2->getResult();

ob_start(); $new = imagecreatetruecolor(120, 150); $fill = imagecolorallocate($new, 0, 0, 0,127); imagecolortransparent($image, $fill); imagefill($image, 0, 0, $fill); imagealphablending($image, false); imagegif($image); $frames[]=ob_get_contents(); $framed[]=150; // Delay in the animation. ob_end_clean(); ob_start();

$fill = imagecolorallocate($image2, 0,0,0, 127); imagecolortransparent($image2, $fill); imagefill($image2, 0, 0, $fill); imagealphablending($image2, false); imagegif($image2); $frames[]=ob_get_contents(); $framed[]=50; // Delay in the animation. ob_end_clean();

$gif = new GIFEncoder($frames,$framed,0,2,0,0,0,'bin');

header('Content-type: image/png'); echo $gif->GetAnimation(); exit; [/code] Original: macthu 2 macthu 3