GD probleempje..

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Johan

Johan

10/09/2005 22:10:00
Quote Anchor link
Hallo iedereen,

Kben bezig met een fotoscriptje, en dat lukt me wel aardig, maar ik stuit, als GD-noob, op een probleem.
//Edit: Omdat niemand reageerde die vraag kom ik maar met een andere in etzelfde topic:

Ik heb de volgende functie gemaatk:
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
<?
Function get_rand_pic($dir1)
  {

    $dir = "./$dir1";
    $num = 1;
    $aant_pics = NumPics($dir);
    $rand = rand(1, $aant_pics-1);
    
    $handle = opendir($dir);
    while($file = readdir($handle))
      {

        if($file != "." || $file != ".." || $file != "")
          {

            $num++;
            if($num == $rand)
              {

                $gezien = 1;
                if($file != " "){ return $file; }
              }
          }
      }
  }

?>

en toegepast op het scriptje van Bas... Nu krijg ik gwoon normaal random pics, maar als ik op vernieuwen druk is er altijd wel (minimaal) 1 die het niet doet. En dan kijk ik in de bron naar welke img die verwijst, dat blijkt dan mapblabla/ te zijn. Voor zo ver ik weet doe ik niks fout.. Wie kan me helpen??

Dank,
Johan.

----------------------------------
Ik zou het leuk vinden, om bij de mappen een image weer te geven, die min of meer inhoud van de map toont, zoiets als:

Afbeelding

Het lijkt me duidelijk dat je foto's moet verkleinen (wat me wel lukt) en dan in een nieuw plaatje over elkaar heen moet schuiven, maar wie kan me op weg helpen met dat laatste??

Bedankt,
Johan...
Gewijzigd op 15/09/2005 20:20:00 door Johan
 
PHP hulp

PHP hulp

16/04/2024 17:49:01
 
Johan

Johan

15/09/2005 20:26:00
Quote Anchor link
Wie??
 
Legolas

Legolas

15/09/2005 20:43:00
Quote Anchor link
kijk eens heel goed naar deze regel:

if($file != "." || $file != ".." || $file != "")

en bedenk je dat || of betekent
 
Johan

Johan

15/09/2005 20:49:00
Quote Anchor link
Bedankt, beetje sgeef van mij..:)

Maar helaas, khep nogsteeds 1tje open.. Nogsteeds op zoek naar img blabla/
 
Jelmer -

Jelmer -

15/09/2005 20:58:00
Quote Anchor link
Je kan de verkleinfunctie gewoon gebruiken:
Quote:
bool imagecopyresampled ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h )
 
Johan

Johan

15/09/2005 21:17:00
Quote Anchor link
Jelmer:
Je kan de verkleinfunctie gewoon gebruiken:
Quote:
bool imagecopyresampled ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h )


Huh??

Om te zorge dat je een goed randomplaatje pakt verkleinfunctie gebruike..??

Kzeg dr ff bij dak blond ben;)
 
Jelmer -

Jelmer -

15/09/2005 21:21:00
Quote Anchor link
nee, antwoord op je laatste vraag, hoe je de plaatjes over elkaar heen laat schuiven.
In de functie die je waarschijnlijk als verkleinfunctie gebruikt, kan je ook de coördinaten instellen waar je hem wilt plakken. Als je die coördinaten dus per plaatje een beetje grotere waarden geeft, krijg je dat effect van jouw voorbeeldplaatje.
 
Johan

Johan

15/09/2005 21:23:00
Quote Anchor link
:D Nice, gaak proberen..!!
 
Johan

Johan

15/09/2005 21:43:00
Quote Anchor link
Hmmmmmm..

Kben GD-noob, maar na veel klooten, proberen, errors kwam ik hierop uit:

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
<?
header("Content-type: image/jpeg");

$a = "1.jpg"; list($w1, $h1, $o1, $p1) = getimagesize($a);
$b = "2.jpg"; list($w2, $h2, $o2, $p2) = getimagesize($b);
$c = "3.jpg"; list($w3, $h3, $o3, $p3) = getimagesize($c);

$dest_width = "50";
$dest_height = "50";

$imga = imagecreatefromjpeg("$a");
$imgb = imagecreatefromjpeg("$b");
$imgc = imagecreatefromjpeg("$c");

$img = imagecreatetruecolor($dest_width,$dest_height);
    
  imagecopyresampled($img, $imga, 10, 0, 0, 0, 50, 50, $w1, $h1);
  imagecopyresampled($img, $imgb, 20, 10, 0, 0, 50, 50, $w2, $h2);
  imagecopyresampled($img, $imgc, 30, 20, 0, 0, 50, 50, $w3, $h3);
  
imagejpeg($img);
imagedestroy($img);

?>


"De afbeelding “http://localhost/zkkmaassluis/fotos/imgeffect.php” kan niet vertoond worden, omdat ze fouten bevat."

Vrijwilligers die me kunne helpe??
 
Jelmer -

Jelmer -

15/09/2005 23:00:00
Quote Anchor link
Laat de header() eens weg, en kijk met je browser in de broncode van het plaatje. Kan je nog foutmeldingen ontdekken?
(ook natuurlijk even voor ontwikkeling error_reporting(E_ALL); bovenaan)
 
Johan

Johan

16/09/2005 11:21:00
Quote Anchor link
Laat ik header() weg dan krijg ik dus een of andere enge code, zoals dat ik een plaatje in textpad ofzow open.. Error reporting heb ik standaard staan tegenwoordig, hij geeft geen errors :(
 
Jelmer -

Jelmer -

16/09/2005 13:40:00
Quote Anchor link
Geen spaties voor of na < ?php en ?>? Geen vreemde echo's in je code staan?
(je kan de header weer terug zetten in dat geval)
 
Johan

Johan

16/09/2005 18:04:00
Quote Anchor link
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<? error_reporting(E_ALL); ?>

<html>
<head>
<title>Image effect</title>

</head>
<body>

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
<?
header("Content-type: image/jpeg");

$a = "1.jpg"; list($w1, $h1, $o1, $p1) = getimagesize($a);
$b = "2.jpg"; list($w2, $h2, $o2, $p2) = getimagesize($b);
$c = "3.jpg"; list($w3, $h3, $o3, $p3) = getimagesize($c);

$dest_width = "50";
$dest_height = "50";

$imga = imagecreatefromjpeg("$a");
$imgb = imagecreatefromjpeg("$b");
$imgc = imagecreatefromjpeg("$c");

$img = imagecreatetruecolor($dest_width,$dest_height);
    
  imagecopyresampled($img, $imga, 10, 0, 0, 0, 50, 50, $w1, $h1);
  imagecopyresampled($img, $imgb, 20, 10, 0, 0, 50, 50, $w2, $h2);
  imagecopyresampled($img, $imgc, 30, 20, 0, 0, 50, 50, $w3, $h3);
  
imagejpeg($img);
imagedestroy($img);

?>


</body>
</html>

S tog niks fout aan, denk ik zow!
 
Han eev

Han eev

16/09/2005 18:35:00
Quote Anchor link
$imga = imagecreatefromjpeg($a);
$imgb = imagecreatefromjpeg($b);
$imgc = imagecreatefromjpeg($c);
zonder quotes!
 
Legolas

Legolas

16/09/2005 18:40:00
Quote Anchor link
dat <html> <head> etc. hoort er niet bij ej.

Alleen dus:

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
<?
header("Content-type: image/jpeg");

$a = "1.jpg"; list($w1, $h1, $o1, $p1) = getimagesize($a);
$b = "2.jpg"; list($w2, $h2, $o2, $p2) = getimagesize($b);
$c = "3.jpg"; list($w3, $h3, $o3, $p3) = getimagesize($c);

$dest_width = "50";
$dest_height = "50";

$imga = imagecreatefromjpeg($a);
$imgb = imagecreatefromjpeg($b);
$imgc = imagecreatefromjpeg($c);

$img = imagecreatetruecolor($dest_width,$dest_height);
    
  imagecopyresampled($img, $imga, 10, 0, 0, 0, 50, 50, $w1, $h1);
  imagecopyresampled($img, $imgb, 20, 10, 0, 0, 50, 50, $w2, $h2);
  imagecopyresampled($img, $imgc, 30, 20, 0, 0, 50, 50, $w3, $h3);
  
imagejpeg($img);
imagedestroy($img);

?>
Gewijzigd op 16/09/2005 18:41:00 door Legolas
 
Johan

Johan

16/09/2005 19:12:00
Quote Anchor link
//edit: Ik wil graag witte 8ergrond.. lukt me wel, maar alleen als ik imagecreate() gebruikt, Ik krijg dan volgende img:

Afbeelding

Gebruik ik imagecreatetruecolor(), dan krijg ik deze img:
Afbeelding

Aan mn script is verder niks fout, anders kreeg ik wel errors, maar het ziet r als volgt uit:

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
26
27
<?

  // Create a new image
  $im = imagecreate(300, 262);

  // Set the white background
  $bg = imagecolorallocate($im, 255, 255, 255);
 
  // List images and get sizes
  $a = "1.jpg"; list($w1, $h1, $o1, $p1) = getimagesize($a);
  $b = "2.jpg"; list($w2, $h2, $o2, $p2) = getimagesize($b);
  $c = "3.jpg"; list($w3, $h3, $o3, $p3) = getimagesize($c);

  // Create images from JPEG
  $imga = imagecreatefromjpeg($a);
  $imgb = imagecreatefromjpeg($b);
  $imgc = imagecreatefromjpeg($c);
    
  // Paste images on the new, big image.
  imagecopyresampled($im, $imga, 00, 0, 0, 0, 150, 150, $w1, $h1);
  imagecopyresampled($im, $imgc, 60, 60, 0, 0, 150, 150, $w2, $h2);
  imagecopyresampled($im, $imgb, 100, 100, 0, 0, 150, 150, $w3, $h3);

  // output the image
  header("Content-type: image/jpg");
  imagejpeg($im);
?>


???
Gewijzigd op 16/09/2005 19:51:00 door Johan
 
Legolas

Legolas

17/09/2005 10:03:00
Quote Anchor link
Dit moet al je problemen oplossen =P:

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?
header("Content-type: image/jpeg");

$max = 250;

$a = "../images/uploadimages/Murcielago-06.jpg";
list($w1, $h1, $o1, $p1) = getimagesize($a);
$b = "../images/uploadimages/enzo_ferrari_top.jpg";
list($w2, $h2, $o2, $p2) = getimagesize($b);
$c = "../images/uploadimages/enzo_ferrari_trequarti.jpg";
list($w3, $h3, $o3, $p3) = getimagesize($c);

$scale = min($max / $w1, $max / $h1);
$tow1 = floor($scale * $w1);
$toh1 = floor($scale * $h1);
$scale = min($max / $w2, $max / $h2);
$tow2 = floor($scale * $w2);
$toh2 = floor($scale * $h2);
$scale = min($max / $w3, $max / $h3);
$tow3 = floor($scale * $w3);
$toh3 = floor($scale * $h3);

$location2x = $tow1 - floor($tow1 / 3);
$location2y = $toh1 - floor($toh1 / 3);
$location3x = $tow2 - floor($tow2 / 3) + $location2x;
$location3y = $toh2 - floor($toh2 / 3) + $location2y;

$dest_width = $location3x + $tow3;
$dest_height = $location3y + $toh3;

$imga = imagecreatefromjpeg($a);
$imgb = imagecreatefromjpeg($b);
$imgc = imagecreatefromjpeg($c);

$img = imagecreatetruecolor($dest_width,$dest_height);
$bg = imagecolorallocate($img, 255, 255, 255);
imageFill($img, 0, 0, $bg);
    
imagecopyresampled($img, $imga, 0, 0, 0, 0, $tow1, $toh1, $w1, $h1);
imagecopyresampled($img, $imgb, $location2x, $location2y, 0, 0, $tow2, $toh2, $w2, $h2);
imagecopyresampled($img, $imgc, $location3x, $location3y, 0, 0, $tow3, $toh3, $w3, $h3);
  
imagejpeg($img);
imagedestroy($img);

?>
 



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.