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

  • Home
  • SEARCH
  • 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 8623345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:15:31+00:00 2026-06-12T07:15:31+00:00

I have dynamic loaded images wich cannot be larger than 115px. I get them

  • 0

I have dynamic loaded images wich cannot be larger than 115px. I get them from an external source so I have no control over it.

I could get the image sizes with:

$list = getimagesize($imagePath);
$width = $list[0];
$height = $list[1];

But now I need to resize if they are larger than 115px. Tried this but it didn’t keep the proportion:

$height = round(($height * $width) / $width);

Can someone help me with this?
Thanks in advance.

  • 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-12T07:15:32+00:00Added an answer on June 12, 2026 at 7:15 am

    You should consider using imagecopyresampled or imagecopyresized.

    If you’re looking to keep the image scaled properly, you’ll have to throw in a bit more arithmetic, but it shouldn’t be too bad.

    Here’s a bit of pseudocode for scaling the image:

    $max_height = 115;
    if ($height > $max_height)
    {
        $scale = $max_height / $height;
        $height = intval($height * $scale);
        $width  = intval($width  * $scale);
    }
    

    Here’s a more generic form for if height and width must be less than 115:

    $max_size = 115;
    if (max($height, $width) > $max_size)
    {
        $scale = $max_size / max($height, $width);
        $height = intval($height * $scale);
        $width  = intval($width  * $scale);
    }
    

    This guarantees that the largest dimension of the image (be it height or width) will be no greater than 115.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have dynamic listview on my android client app that receive data from remote
I have dynamic array filled with bytes, which are read from .raw file with
I want to create ASP.NET 4.0 dynamic pages loaded from my MS SQL server.
I would like to generate a dynamic image from a script, and then have
These images are loaded dynamically: <div id=gallery-images class=gallery-control> <ul> <img class=galleryImgs data-src=images/test-image-1.jpg src=images/test-image-1-s.jpg />
EDITED for clarity: I want to load all kinds of images from an external
I have a dynamic list loaded into a HTML 5 web app built using
I have a page with dynamic data loaded by some ajax and lots of
Dynamic libraries are nice. The have embedded information in them that help the runtime
I have a dynamic archive (a folder on my ftp space) where are loaded

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.