Jump to content
rootKID

How to make a Picture Resizer? Oo..

Recommended Posts

Hello W3S people again. once again im in a little need of help. at least to get it started, im a little lost in this matter...im in the half-way exams at this week. and we got told to make a admin system that could upload images to products... that part i (CAN) do...but here comes my problem... i dont know the part of resizing the images...any ideas or suggestions would be pretty awsome! and thats not for kidding...i just need a little help for the beginning of it, so i can see the syntax... Hoping answers or suggestions soon!... thanks alot in advance! :).

  • Like 1

Share this post


Link to post
Share on other sites

I just preload a pic inside a div with a preset height and width and use a form to manipulate the properties I've built in the script. Image margin and width and height ( as % of the px) allow me to crop the pic in seconds.

Edited by niche

Share this post


Link to post
Share on other sites

thanks for the advice... but that part i allready know on how to do... that is actually pretty easy if you ask me :P... but the problem lies in that part that we (have) to do the resize if we can... i can't right now... but im at least trying... PS: is there not a way to do this in PHP coding?...

Share this post


Link to post
Share on other sites
thanks for the advice... but that part i allready know on how to do... that is actually pretty easy if you ask me :P... but the problem lies in that part that we (have) to do the resize if we can... i can't right now... but im at least trying... PS: is there not a way to do this in PHP coding?...
There is... go to: http://php.net/manual/en/book.image.php
  • Like 1

Share this post


Link to post
Share on other sites

As a practical matter how is imagecopyresampled() different from adjusting a pic's height% and width% with css? I understand the the processes are different, but what are the advantages, over css, demonstrated by #1 & #2 example at http://php.net/manual/en/function.imagecopyresampled.php ?

Share this post


Link to post
Share on other sites

Styling with CSS still causes the entire file to be transferred from the server, and the resizing performed by the browser does not include resampling so the picture looks less smooth. If you actually resize the file then you don't need 1MB to download a picture that you're going to show at only 300x200.

  • Like 1

Share this post


Link to post
Share on other sites

That's worth knowing when I use large images. Thanks Don E and jsg.

Share this post


Link to post
Share on other sites

ok, thanks.. will try out the stuff... been helpfull so far... thanks! :)..

Share this post


Link to post
Share on other sites

hello again, just a fast question... i am trying to make a small if statement... like so:

($k_row['til_dag'] == 0) ? "": "$k_row[til_dag]";

but its not numbers im getting out, but words... so am i stupposed to use the (== 0)?... or what else should i use?... thanks in advance... :)...

Share this post


Link to post
Share on other sites

Did you really mean "$k_row[til_dag]" or do you want $k_row['til_dag']? If not, please provide more context.

Share this post


Link to post
Share on other sites

if you are triyng to validate only alphanum you can use http://php.net/ctype_alnum

Share this post


Link to post
Share on other sites

sorry for late reply all... and thanks birbal, i will read up upon it... and niche, i did mean ("$k_row[til_dag]")... what diffrence does it makes?...

Share this post


Link to post
Share on other sites

Well in the ternary, in post #10, if your first condition doesn't equal 0 text is returned. "$k_row[til_dag]" is text obviously.

Share this post


Link to post
Share on other sites

PHP does variable interpolation in between double quotes. What I don't see is the how the OP is getting a value from that line, since is he just checking the condition, not doing anything with it. Can the entire code be posted? What is text that you aren't expecting to be text? Have you debugged to check it's value before and after you do anything to it? You need to debug and show us all the relevant code and tell us what is/isn't working.

Share this post


Link to post
Share on other sites

lol... i have allready finded out, it was a freaking (echo) statement i forgot.. sorry guys, allready done the job... but to try finish what i was going to tell, then i was trying to output somfthing from db (the days names... Monday,Friday,ect...) and then some hours like (11.pm-10-am,ect...) to show people in a shop im making when the shop is open and go on... but that is fixed and done now...so no worries... so the if statement worked/works ;)...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...