Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the distortion of php gd Library

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to solve the distortion of php gd library". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Php gd library distortion solutions: 1, open the corresponding PHP file; 2, through the imagecreatetruecolor function to create a canvas of the same size as the background image; 3, according to the actual needs to cover up the required pictures.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

How to solve the problem of php gd library distortion?

The problem of Image distortion in PHP drawing based on GD

Make a little thing these two days, and the pictures are superimposed and combined into a new picture. The cut picture uses the copper plug-in, and the effect is terrible. The picture is distorted, and the distortion is similar to the loss of detail color of GIF motion pictures on the Internet. So I found the following solution on the Internet, and the personal test is effective.

The most critical step is to create a canvas that is the same size as the background image using the imagecreatetruecolor (aline b) function.

$bgimg = imagecreatetruecolor (imagesx ($im), imagesy ($im))

With this $bgimg as low, pass the

Imagecopymerge ($bgimg,$im, 0,0,0,0 im imagesx, imagesy ($im), 100)

Cover the original buckle bottom image $im, and then cover up the required pictures according to the actual needs.

Of course, it is also possible to add words.

Imagefttext ($bgimg, $name_font, 0, $name_orginX, $name_orginY, $color, $font, $name)

Last

Header ('Content-type: image/png'); header (' Content-type: image/jpg'); $result = imagepng ($bgimg); imagedestroy ($bgimg)

This is not all the code, but anyone who knows GD should know where to put it.

This is the end of the content of "how to solve the distortion of php gd Library". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report