Page 1 of 1

Need help with image Resizing

Posted: Tue Sep 21, 2004 10:35 am
by wizzard81
Hello,

I have installed the GD library on my apache webserver but need some help with resizing images that will be showed on the main page of my website.

Well if images will be like 640x480 i wan to resize them like this 150x200 so i set always the height of the image on 200 but i want if the image is largen then 150 pixels to cut out till the image is 150x200. So first i will set the height to 200.

Can someone helps me or knows a good tutorial about this?

Posted: Tue Sep 21, 2004 10:55 am
by feyd
it's simple math to figure it out... original_width / original_height * new_height = new_width.

Posted: Tue Sep 21, 2004 11:32 am
by wizzard81
But do you know the function of GD. Because my problem is i will have more then 1000 images. So i want to resize my image and cut out the part thats bigger.

Posted: Tue Sep 21, 2004 11:41 am
by anjanesh
Similar code here :
viewtopic.php?t=25346

Posted: Tue Sep 21, 2004 11:42 am
by feyd
have you even tried reading the [php_man]gd[/php_man] function list page? There are 2 right in a row that say resize in there description. :?

Posted: Tue Sep 21, 2004 1:58 pm
by wizzard81
Yes i did but let me explain what i want first if the image is like 640x480 i want to resize to a height of 200px then the width is 267px then i want to crop out 67 pixels of the width. Is something like this possible?

Posted: Tue Sep 21, 2004 2:04 pm
by feyd
yes... you just copy a region of the scaled down image..

Posted: Tue Sep 21, 2004 2:27 pm
by timvw
wizard81: willem? of jeroen? :P



btw, phpthumb.sourceforge.net does everything you want.

Posted: Tue Sep 21, 2004 4:15 pm
by wizzard81
Timvw no i'm Kris :)

Thanks feyd for the help.

Posted: Tue Sep 21, 2004 4:43 pm
by wizzard81
I still have a little question of you set the height on 200 doesn't the functions sets automatic the width. Like if you set the height of an image of 640x480 to 200 then the width should be 267px.

Because after this i can crop the 67pix out of it. Is something maybe possible? The best thing would be for me if have an image that i can get the height on 200 width on 200pix in a variable so that the real image not will be changed but it's only necessary to show the latest images in a gallery and on the main of my site.

Posted: Tue Sep 21, 2004 6:12 pm
by feyd
the width in determined by you.. it doesn't automatically know you want to scale in 1:1.. maybe you want 1:3 scaling...