程序运行但没有成功

时间:2019-03-14 21:28:55

标签: php gd

我有以下内容:

brew

... / includes / functions.php:

此功能已从我在此处找到的源代码进行了修改rounded.php

<?php
   require ("../includes/functions.php");

   if (extension_loaded('gd') && function_exists('gd_info')) {
      echo "PHP GD library is installed on your web server !!";
   }else{
      echo "PHP GD library is NOT installed on your web server";
   }  

   $gd =  rounded();      
   echo "<br>";
   print($gd);
?>

运行上面的命令时,我得到:

function rounded(){       

   $image_file = "sailwBob&Russ.png";
   $corner_radius =  20;                  // The default corner radius is set to 20px
   $angle =  0;                           // The default angle is set to 0º
   $topleft     =  false;                 // Top-left rounded corner is shown by default
   $bottomleft  =  true;                  // Bottom-left rounded corner is shown by default
   $bottomright =  true;                  // Bottom-right rounded corner is shown by default
   $topright    =  true; 



   $images_dir = 'img/';
   $corner_source = imagecreatefrompng('img/rounded_corner.png');

   $corner_width = imagesx($corner_source);  
   $corner_height = imagesy($corner_source);  
   $corner_resized = ImageCreateTrueColor($corner_radius, $corner_radius);


   ImageCopyResampled($corner_resized, $corner_source, 0, 0, 0, 0, $corner_radius, $corner_radius, $corner_width, $corner_height);



   $corner_width = imagesx($corner_resized);  
   $corner_height = imagesy($corner_resized);  
   $image = imagecreatetruecolor($corner_width, $corner_height);  
   $image = imagecreatefrompng($images_dir . $image_file);                  // replace filename with $_GET['src'] 
   $size = getimagesize($images_dir . $image_file);                        // replace filename with $_GET['src'] 
   $white = ImageColorAllocate($image,255,255,255);
   $black = ImageColorAllocate($image,0,0,0);

   print_r2($size);
   print_r2($image);

   // Top-left corner
   if ($topleft == true) {
       $dest_x = 0;  
       $dest_y = 0;  
       imagecolortransparent($corner_resized, $black); 
       imagecopymerge($image, $corner_resized, $dest_x, $dest_y, 0, 0, $corner_width, $corner_height, 100);
   } 

   // Bottom-left corner
   if ($bottomleft == true) {
       $dest_x = 0;  
       $dest_y = $size[1] - $corner_height; 
       $rotated = imagerotate($corner_resized, 90, 0);
       imagecolortransparent($rotated, $black); 
       imagecopymerge($image, $rotated, $dest_x, $dest_y, 0, 0, $corner_width, $corner_height, 100);  
   }

   // Bottom-right corner
   if ($bottomright == true) {
       $dest_x = $size[0] - $corner_width;  
       $dest_y = $size[1] - $corner_height;  
       $rotated = imagerotate($corner_resized, 180, 0);
       imagecolortransparent($rotated, $black); 
       imagecopymerge($image, $rotated, $dest_x, $dest_y, 0, 0, $corner_width, $corner_height, 100);  
   }

   // Top-right corner
   if ($topright == true) {
       $dest_x = $size[0] - $corner_width;  
       $dest_y = 0;  
       $rotated = imagerotate($corner_resized, 270, 0);
       imagecolortransparent($rotated, $black); 
       imagecopymerge($image, $rotated, $dest_x, $dest_y, 0, 0, $corner_width, $corner_height, 100);  
   }

   // Rotate image
   $image = imagerotate($image, $angle, $white);

    print_r2($image);

   // Output final image
   imagepng($image,$images_dir . "test.png");

   // Remove temp files
    imagedestroy($image);  
    imagedestroy($corner_source);


   return ("looks like rounded() ran");
} 

它会在正确的位置生成test.png,但不会使图像的任何角落变圆

在public_html下,我有:

PHP GD library is installed on your web server !!
Array
(
    [0] => 540
    [1] => 58
    [2] => 3
    [3] => width="540" height="58"
    [bits] => 8
    [mime] => image/png
)
Resource id #8
Resource id #13

looks like rounded() ran

我在公共场合有

public_html
   skipper
      includes
      public
      views

第一个程序已公开运行

0 个答案:

没有答案