I'm trying to resize uploaded images so they fit into a slideshow.

Specifically, I'm interested in the height of the image as the slider doesn't handle different heights too well.

So I've implemented the code below:

function resizePhoto($ht,$fname,$dest,$pref,$SRCPath){
    echo 'Image data is corrupt, cannot process file:'.$fname;
    echo '<br>'.$image_path.'<br>';
    return '';
  return $fname;

I call this using something like the following: resizePhoto(500,'IMG00012.JPG','gallery/resized/','tmp/')

I'm expecting the height to be 500 pixels, and I'm using $wd=$image_atts[0]*($ht/$image_atts[1]); to find out the appropriate width for the aspect ratio.

However, the width of the images are 500 pixels and it is the height which is varying.

For the life of me, I can't see where my code is going wrong.

Maybe it needs a fresh pair of eyes.

Recommended Answers

All 2 Replies

Hi, try to round the result of $wd because if for example this is a 4:3 it would return 666,67 i.e. a float, where instead imagecreatetruecolor()expects an integer.


I think that may be it!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.