Program runs but doesn't round corners

24
March 16, 2019, at 02:10 AM

I have the following:

<?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);
?>

.../includes/functions.php :

The function was modified from source code I found here rounded.php

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");
} 

When I run the above I get:

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

it produces test.png in the right location but doesn't round any of the corners of the image

under public_html i have:

public_html
   skipper
      includes
      public
      views

in public I have:

public
   img

the first program is run out of public

READ ALSO
Redirect automatically from Woocommerce thankyou to an external link passing variables

Redirect automatically from Woocommerce thankyou to an external link passing variables

In Woocommerce, after placing an order, I Would like to redirect customer automatically after 5 sec from the thankyou page to external link passing a few variables as the order_id, and the order_ammount

9
what is the best database management systeme to use for large chat website? [on hold]

what is the best database management systeme to use for large chat website? [on hold]

actually i ma sedigning a new database for a quite large chat website with some friends, but we think that phpmyadmin isn't that good for, so i need to what DBMS is the best for that, for example what facebook database uses?

13
PHP - Iterate through file and break out chunks of text for JSON

PHP - Iterate through file and break out chunks of text for JSON

I have a file on a server that I need to parse and build a JSON object to returnI am using PHP

39