From previous experiences, I've noticed that I'm not very good at integrating 'scripts' created by others, with my own existing code, as of now. I need some advice on understanding what this person is saying about resizing images with PHP:
In the comments, he's written:
// Parameters need to be passed in through the URL's query string:
// image absolute path of local image starting with "/" (e.g. /images/toast.jpg)
// width maximum width of final image in pixels (e.g. 700)
// height maximum height of final image in pixels (e.g. 700)
Then, he gives an actual example, also as a comment:
// Resizing and cropping a JPEG into a square:
// <img src="/image.php/image-name.jpg?width=100&height=100&cropratio=1:1&image=/path/to/image.jpg" alt="Don't forget your alt text" />
I am guessing, he wants the user of the script to have something similar to the above img src
. So, my question is: How will I actually make the source of my pictures similar to the example above? Below is some of the code I have. It shows how I am saving the pictures and HOW I am echoing/displaying them. It's from uploader.php
:
move_uploaded_file($_FILES["file"]["tmp_name"],
"profileportraits/" . $_FILES["file"]["name"]);
echo "Stored in: " . "profileportraits/" . $_FILES["file"]["name"];
Once the photo has been saved in the folder, I save the file path in a MySQL table and later call the file path to display the picture (Below Code). It's from profile.php
echo "<img src=\"{$row['PortraitPath']}\" />";
Therefore, how will I pass the parameters similar to the one in the 'script example' if I am using the above img src to display the 'actual' picture?
THANK YOU.
You can use the following code to resize the image... once you got all the params
Hope this helps..
Thanks Chetan sharma