Use GD to create thumbnail of jpg, gif, png, or bmp

I'm looking for a PHP function to generate a thumbnail of a jpg, gif, png or bmp file, and save it to a file.

I also don't want to define a max width or max height, I want to be able to specify a width and height, and have the thumbnail scale to fit the new size.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Just a quick search:

Otherwise, you could try searching/browsing around at the root site,

Good luck,


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BreadstickAuthor Commented:
Thanks, but that doesn't scale to a new height and width, it scales proportionatly.
add in one function to the class:
      function my_size($height=100, $width=100)

then when you call, use this:
Sample :
//you can change your own...
$thumb=new thumbnail("./shiegege.jpg");                  // generate image_file, set filename to resize
$thumb->my_size($myheight, $mywidth);                  // set the biggest width or height for thumbnail
$thumb->jpeg_quality(75);                        // [OPTIONAL] set quality for jpeg only (0 - 100) (worst - best), default = 75
$thumb->show();                              // show your thumbnail
$thumb->save("./huhu.jpg");                        // save your thumbnail to file
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

I use phpThumb for on the fly thumbnails.

The output size is configurable (can be larger or smaller than the source), and the source may be the entire image or only a portion of the original image. True color and resampling is used if GD v2.0+ is available, otherwise paletted-color and nearest-neighbour resizing is used.

Hope this helps.

Hi BreadStick.

Does the extra function help you?
I have used the code and it works for me.

If it is useful, it will be very much appreciated if you could close the thread. :)

Thanks in advance.
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:
Split: kingsburymedia &  WoodyRoundUp

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.