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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:07:21+00:00 2026-05-20T12:07:21+00:00

I want to resize the images to fixed width and height (i.e. 150px). However,

  • 0

I want to resize the images to fixed width and height (i.e. 150px). However, theres a problem, if there is lots of difference in height and width of original photo (for example, panoramic photo), the resized thumbnail looks bad. Is there any any smart solution to resize the photos to a fixed width and height? For example, please have a look at this
image:
enter image description here

Here’s my code:

<?php
    $params = getimagesize($tempFile);
    $width = $params[0];
    $height = $params[1];

    $newwidth=150;
    $newheight= 150;
    $tmp=imagecreatetruecolor($newwidth,$newheight);

    imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
    imagejpeg($tmp,$img_name,80);

    imagedestroy($src);
    imagedestroy($tmp); 
?>

Is there any smart way to resize the images in smart way?
Thanks.

  • 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-20T12:07:21+00:00Added an answer on May 20, 2026 at 12:07 pm

    There’s a smart solution, it’s called Seam Carving, and if your server supports ImageMagick, you do it like this:

    <?php
    $im = new Imagick( 'image.jpg' );
    $im->liquidRescaleImage( 600, 100, 3, 25 );
    header( 'Content-Type: image/jpg' );
    echo $im;
    ?>
    

    Or alternatively, if it doesn’t support, use exec() (carefully) in order to pass image as an argument to executable which can perform seam carving.

    BTW it looks like twitpic just crop’s the squared image extract.
    In one of my previous projects I used following code:

    if ($image->width > $image->height){
        //crop image in proportions 4/3, then resize to 500x300 (or proportionally lower resolution), 
        //sharp it a little and decrease quality. 
        //I used one of the Yii framework extensions.
        $image->crop($image->width, $image->width/4*3)->resize(500, 300, Image::WIDTH)->sharpen(15)->quality(75);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I want to resize images to a FIXED width, but proportional height. I
I want to resize the new images in a height and width of 800px
I'm using RMagick and want my images to be resized to a fixed width
I want to resize cell's height according to the label's height and label's height
I want to resize images that are bigger than the window, but I keep
I want to resize bmp images in codeigniter. How do i do that. Codeigniter
I have a UIButton of fixed width and I want to place text in
I want to resize images using php. with out losing its quality. Currently I
I am uploading some image files using servelt. I want to resize the images.
Aim: To resize the images based on the resolution Problem : If we do

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.