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 6022361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:50:50+00:00 2026-05-23T03:50:50+00:00

Hi I want to resize image when in display on details section. For that

  • 0

Hi I want to resize image when in display on details section. For that I checked many PHP scripts but its not working in my locale. Some scripts showing image path must start with / but when I give like that its shows image is not found. Also most of the scripts demo page shows fake images.

  • 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-05-23T03:50:51+00:00Added an answer on May 23, 2026 at 3:50 am

    Best option is crop image while image upload. Please find below code for image crop using GD library may it help you.

    <?php
    function createThumb($upfile, $dstfile, $max_width, $max_height){
       $size = getimagesize($upfile);
       $width = $size[0];
       $height = $size[1];
       $x_ratio = $max_width / $width;
       $y_ratio = $max_height / $height;
       if( ($width <= $max_width) && ($height <= $max_height)) {
               $tn_width = $width;
               $tn_height = $height;
    
       } elseif (($x_ratio * $height) < $max_height) {
               $tn_height = ceil($x_ratio * $height);
               $tn_width = $max_width;
    
       } else {
               $tn_width = ceil($y_ratio * $width);
               $tn_height = $max_height;
    
       }
       if($size['mime'] == "image/jpeg"){
    
               $src = ImageCreateFromJpeg($upfile);
               $dst = ImageCreateTrueColor($tn_width, $tn_height);
               imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
               imageinterlace( $dst, true);
               ImageJpeg($dst, $dstfile, 100);
       } else if ($size['mime'] == "image/png"){
               $src = ImageCreateFrompng($upfile);
               $dst = ImageCreateTrueColor($tn_width, $tn_height);
               imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
               Imagepng($dst, $dstfile);
    
       } else {
    
               $src = ImageCreateFromGif($upfile);
               $dst = ImageCreateTrueColor($tn_width, $tn_height);
               imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
               imagegif($dst, $dstfile);
       }
    }
    
    //usage
    
    if(isset($_FILES['upload_Image']['name']) && $_FILES['upload_Image']['name']!=='') {
        $ext = substr($_FILES['upload_Image']['name'], strpos($_FILES['upload_Image']['name'],'.'), strlen($_FILES['upload_Image']['name'])-1); 
    
        $imgNormal = time().$ext;
        $normalDestination = "Photos/Orignal/" . $imgNormal;
        $httpRootLarge = "Photos/Large/" . $imgNormal;
        $httpRootSmall = "Photos/Small/" . $imgNormal;
        $httpRootThumb = "Photos/Thumb/" . $imgNormal;
        move_uploaded_file($_FILES['upload_Image']['tmp_name'], $normalDestination);
        createThumb($normalDestination,$httpRootLarge,680,604); #For 604x604 Image 
        createThumb($normalDestination,$httpRootSmall,500,300); #For 500x300 Image
        createThumb($normalDestination,$httpRootThumb,130,100); #For 130x100 Image
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my php that retrieves image from mysql database. I want to resize
I want that when i resize the form, Image Display resize with form size
I have an image that I want to resize on my websites rendering using
I have an image . I want to resize it using PIL, but it
JavaScript. I want to create simple script, that will be resize loaded image using
I want to create a WebView to display an image. But on the second/third
If I have an image that is 600x600 and I want to display it
I have a 16x16 pixel image that I want to display in an UIImageView.
I want to resize an image on the sd card and send it to
I want to load an image, resize it to a given size and after

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.