PHP meerdere images naar één: niet zwart-wit!

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Tom aan t Goor

Tom aan t Goor

17/07/2013 19:13:34
Quote Anchor link
Hoi,

Ik heb een stuk code gemaakt, om meerdere .png bestanden naar 1 .png bestand te maken.
Dit doe ik door ze onder elkaar te zetten.

Alleen nu heb ik het probleem dat alles in zwart-wit is, en dit begrijp ik niet.
Kan iemand me dit uitleggen?
(Ook is de background transparant.)

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
$location
= 'images/';
$images = array('dots.png', 'footer.png');

for($i=0;$i<count($images);$i++){
    $src[$i] = imagecreatefrompng($location.$images[$i]);
    list($src[$i.'-w'], $src[$i.'-h'], $src[$i.'-t'], $src[$i.'-a']) = getimagesize($location.$images[$i]); // width - height - type - attribute
    $totalheight += $src[$i.'-h'];
    if($src[$i.'-w'] > $totalwidth){
        $totalwidth = $src[$i.'-w'];
    }
}


$dest = imagecreate(300, 300);

for($i=0;$i<count($images);$i++){
    imagecopy($dest, $src[$i], 0, $nowheight, 0, 0, $src[$i.'-w'], $src[$i.'-h']);
    $nowheight += $src[$i.'-h'];
}


header('Content-Type: image/png');
imagepng($dest);

imagedestroy($dest);
?>
Gewijzigd op 17/07/2013 19:13:49 door Tom aan t Goor
 
PHP hulp

PHP hulp

28/03/2024 17:06:37
 
Goeny Goegoe

Goeny Goegoe

17/07/2013 20:56:15
 
Tom aan t Goor

Tom aan t Goor

17/07/2013 22:13:06
Quote Anchor link
Ik heb nu dit staan, alleen afbeeldingen met een witte achtergrond wordt nu ook transparant, en dat is niet de bedoeling.
En afbeeldingen met een overloop van transparant naar wit/geel wordt nu zwart.
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
<?php
$dest
= imagecreatetruecolor(300, 300);
imagealphablending($dest, true);
$black = imagecolorallocate($dest, 0,0,0);
imagecolortransparent($dest, $black);
?>
Gewijzigd op 17/07/2013 22:20:57 door Tom aan t Goor
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.