resize image with PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lammspillning
Forum Newbie
Posts: 14
Joined: Fri Aug 17, 2007 10:50 am

resize image with PHP

Post by lammspillning »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I've been stucked with this problem for a while now and cant get it to work..

I have a code that upload and renames a image. 
Now I want that image to be resized to 700*525 pixels, and overwrite the big uploaded image with the small resized image.
I have tested many examples I found, but I dont get it to work..

this is the code I have to upload and rename the image, can someone [s]plz[/s] [size=150][color=green]please[/color][/size] show me the code that is needed and where to put it in my existing code..//[s]thnx[/s] [size=150][color=green]thanks[/color][/size]

Code: Select all

<?php
//create the directory if doesn't exists (should have write permissons)
if(!is_dir("./files")) mkdir("./files", 0755); 

//move the uploaded file
move_uploaded_file($_FILES['Filedata']['tmp_name'], "MY_IMG.jpg");

?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]11.[/b] Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.[/quote]
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: resize image with PHP

Post by superdezign »

lammspillning wrote:this is the code I have to upload and rename the image, can someone plz show me the code that is needed and where to put it in my existing code..//thnx
You're asking for too much.
Look into the GD library, specifically imagecopyresize() and imagecopyresample()
lammspillning
Forum Newbie
Posts: 14
Joined: Fri Aug 17, 2007 10:50 am

Post by lammspillning »

ok sorry, I know I'm asking for much.. I'ts just that I tried to paste example code a number of times and never get it to work..
//thanx anyway
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

lammspillning wrote:I'ts just that I tried to paste example code a number of times and never get it to work..
Which is why you need to make sure you understand the code instead of pasting it... Exactly the reason why I didn't just give you a snippet. If you don't understand it, you don't learn it, and your cripple yourself. Take the time and effort to understand what works and why.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

At minimum, show us what you have tried.
Post Reply