I wanted to show image from another server, but a smaller image maintaining the aspect ratio and i will not be knowing the exact size of that image. Can i do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First you need to grab the image from another server, for that you can use
file_get_contents().Then you need some code to resize an image. Since you have the image content in a string rather than a local file, you can use
imagecreatefromstring()try here:curl and resize remote image
If you want to resize it down relative to the original then use
getimagesizefromstring()to get the current size, then simply calculate the new size based on your chosen percentage.