Gd library-I beg you, how does php automatically scale the watermark according to the image size?

Source: Internet
Author: User
Hello everyone, I recently worked on a watermark program. I used the GD library to add several watermarks to a graph, but the image size is not fixed. This causes the watermark to be suddenly large or small. How can we achieve this function? Hello everyone, I recently worked on a watermark program. I used the GD library to add several watermarks to a graph, but the image size is not fixed. This causes the watermark to be suddenly large or small. How can we achieve this function?

Reply content:

Hello everyone, I recently worked on a watermark program. I used the GD library to add several watermarks to a graph, but the image size is not fixed. This causes the watermark to be suddenly large or small. How can we achieve this function?

Simply put, the solution logic is ready for you to think about.
Step 1: First set an image size that complies with the existing watermark. for example, the image with a watermark of 500*500 or more is very beautiful.
The solution to access is simple. to get the image width and height, you only need to go through the following process as long as it exceeds 500*500:
1: calculate the proportion: such as 100*250, calculate the proportion such as width/500 = 0.2 high/500 = 0.5
2: scale the watermark and paste it again.
You should have understood this clearly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.