gd library - I beg you all, how can PHP automatically scale the watermark according to the image size?

WBOY
Release: 2016-08-18 09:16:28
Original
1326 people have browsed it

Hello everyone, I am currently working on a watermark program, using the GD library. I want to put several watermarks on a picture, but the picture size is not fixed. As a result, the watermark is suddenly large and sometimes small. I pray to God to guide me, how can I achieve such a function?

Reply content:

Hello everyone, I am currently working on a watermark program, using the GD library. I want to put several watermarks on a picture, but the picture size is not fixed. As a result, the watermark is suddenly large and sometimes small. I pray to God to guide me, how can I achieve such a function?

Simple explanation of the solution logic, you will know how to write it after thinking about it.
Step 1: First set a picture size that matches the existing watermark. For example, pictures above 500*500 will look very beautiful after being watermarked.
Then it is very simple to solve the access problem. Get the width and height of the image. As long as it exceeds 500*500, go through the following process:
1: Calculate the ratio: such as 100*250, calculate the ratio, such as width/500=0.2 height/500=0.5
2: Scale the watermark and then paste it.
It’s explained so clearly that you should understand it.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!