Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8388281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:26:27+00:00 2026-06-09T18:26:27+00:00

func.php file where it generates a thumbnail when an image is uploaded to website.

  • 0

func.php file where it generates a thumbnail when an image is uploaded to website. I understand how to make the corners rounded by radius of 5 but for some reason I am stumped right now where to incorporate the round corners into my code, please help:

<?php
function create_thumb($directory, $image, $destination) {
  $image_file = $image;
  $image = $directory.$image;

if (file_exists($image)) {

$source_size = getimagesize($image);

if ($source_size !== false) {

  $thumb_width = 100;
  $thumb_height = 100;

  switch($source_size['mime']) {
    case 'image/jpeg':
         $source = imagecreatefromjpeg($image);
    break;
    case 'image/png':
         $source = imagecreatefrompng($image);
    break;
    case 'image/gif':
         $source = imagecreatefromgif($image);
    break;
  }

  $source_aspect = round(($source_size[0] / $source_size[1]), 1);
  $thumb_aspect = round(($thumb_width / $thumb_height), 1);

  if ($source_aspect < $thumb_aspect) {
    $new_size = array($thumb_width, ($thumb_width / $source_size[0]) * $source_size[1]);
    $source_pos = array(0, ($new_size[1] - $thumb_height) / 2);
  } else if ($source_aspect > $thumb_aspect) {
    $new_size = array(($thumb_width / $source_size[1]) * $source_size[0], $thumb_height);
    $source_pos = array(($new_size[0] - $thumb_width) / 2, 0);
  } else {
    $new_size = array($thumb_width, $thumb_height);
    $source_pos = array(0, 0);
  }

  if ($new_size[0] < 1) $new_size[0] = 1;
  if ($new_size[1] < 1) $new_size[1] = 1;

  $thumb = imagecreatetruecolor($thumb_width, $thumb_height);
  imagecopyresampled($thumb, $source, 0, 0, $source_pos[0], $source_pos[1], $new_size[0], $new_size[1], $source_size[0], $source_size[1]);

  switch($source_size['mime']) {
    case 'image/jpeg':
         imagejpeg($thumb, $destination.$image_file);
    break;
    case 'image/png':
          imagepng($thumb, $destination.$image_file);
    break;
    case 'image/gif':
         imagegif($thumb, $destination.$image_file);
    break;
  }


}

  }
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:26:29+00:00Added an answer on June 9, 2026 at 6:26 pm

    This code looks like its part of the image making process
    To style the image, you need to be working on the output of that file

    Do you have code that generates HTML for the client side?
    If so, then give each img a class and use CSS to give it the corners

    .ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my problem. I have one file (say, func.inc.php) with autoloader function, registered
My main website references this php file at the beginning of the document like
<?php error_reporting(E_ALL); include func.php; connectToDatabase(localhost,root,,test); $fileName = $_FILES['name']; $fileSize = $_FILES['size']; $fileType = $_FILES['type'];
Super noob question here... The file source: www.mysite.com/blah/blah/customdir/ajax/folder/file.php and I want to include a
I am working on a command line php file, and I tried to use
Consider the following situation file: ./include/functions/table-config.php containing: . . $tablePages = 'orweb_pages'; . .
func.js : $.get( test.php, {id: theid}, function(data){...} ) My test.php and func.js files are
How can I accomplish http://php.net/manual/en/function.call-user-func-array.php in ruby? So I can do this: class App
i have two php files where one is executed through url and that file
I am getting following notice in WordPress Notice: Undefined index: _wpnonce in /var/www/vhosts/abc.biz/php/func.php on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.