Archivlink: javarea.de Forum > PHP, MySQL & CGI > ImageCopy
Vollständigen Link anzeigen: javarea.de Forum > PHP, MySQL & CGI > ImageCopy

Pages: [1]

geschrieben von JDEmp am 27.06.2007 - 23:08
Hallo alle zusammen,
Ich quelle mich nun schon den ganze Tag mit diesem Thema und komme einfach nicht weiter. Ich würde ganz gerne ein Bild erstellen und ein Teil eines anderes Bildes in dieses einfügen. So weit so gut.

PHP-Quelltext
1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 
11: 
12: 

<?
function bild ()
    {
        
$bild imagecreatefrompng("DE.png");

        
Header("Content-type: image/png");
        
Imagepng($bild);
        
ImageDestroy($bild);
    }

    echo 
"<img src=\"".bild()."\" width=\"18\" height=\"12\" alt=\"\">"
?>



Das ist das Grund-Script funktioniert. Das Ursprungsbild wird dargestellt. Nun gehe ich einen Schritt weiter und versuche ein Teil eines Bildes in dieses einzufügen.

PHP-Quelltext
1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 
11: 
12: 
13: 
14: 

<?
function bild ()
    {
        
$bild imagecreatefrompng("DE.png");

        
imagecopy($bild"KR.png""0""0""9""0""9""12");

        
Header("Content-type: image/png");
        
Imagepng($bild);
        
ImageDestroy($bild);
    }

    echo 
"<img src=\"".bild()."\" width=\"18\" height=\"12\" alt=\"\">"
?>



Und nun bekomme ich die Fehlermeldung: "imagecopy(): supplied argument is not a valid Image resource in" Und ich versteh einfach nicht wieso. Ich habe hier mal die beiden Bilder angehängt. Beide Bilder haben die Mase: Width=18 height=12.

geschrieben von René am 28.06.2007 - 07:22
PHP-Quelltext
1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 
11: 
12: 
13: 
14: 
15: 

<?php

$bild1 
imagecreatefrompng('./original.png');
$bild2 imagecreatefrompng('./copy.png');

imagecopy($bild1$bild20090912);

header('Content-type: image/png');

imagepng($bild1);
imagedestroy($bild1);

?>


geschrieben von JDEmp am 01.04.2008 - 17:26
Auch wenn es sehr spät kommt :S – Danke!

PHP-Quelltext
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: 
26: 
27: 
28: 
29: 
30: 

<?php
    
function bild ($landa$landb "")
    {
        if (!empty(
$landa) && !empty($landb))
        {
            
$bilda imagecreatefrompng($landa.".png");
            
$bildb imagecreatefrompng($landb.".png");

            
imagecopy($bilda$bildb0000912);

            
Header("Content-type: image/png");

            
Imagepng($bilda);
            
ImageDestroy($bilda);
        }
        else
        {
            
$bilda imagecreatefrompng($landa.".png");

            
Header("Content-type: image/png");

            
Imagepng($bilda);
            
ImageDestroy($bilda);
        }
    }

    echo 
"<img src=\"".bild("DE""KR")."\" width=\"18\" height=\"12\" alt=\"\" />\n";
?>



Powered by: JBB v.2.0.4 Copyright ©2000-2006, www.javarea.de.