Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem that there is no pigmentation in dynamically generated gif images

Shulou Source: shulou.com Published: 2022-06-03 06:08:24 10月04日 Update

In this issue, the editor will bring you about how to solve the problem of dynamic generation of gif format images without pigment modification. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

If you use intimagecreatefromgif (stringfilename); to take out a GIF format and use it as a background or basic canvas sample, draw on it, please note: if there is no pigment in this file, you will not be able to use it. The following editor to explain the dynamic generation of gif format image without pigment change how to solve?

How to dynamically generate an image in gif format without pigment modification?

The solution, you can use

Intimagecreate (intx_size,inty_size)

Create an empty picture. Draw a graph on it. Use black as the transparent color.

The new drawing should be the same size and absolute position as the original one. Just put it on top of the original one.

Original drawing file

All-empty file photo.php

The code for photo.php:

How to dynamically generate an image in gif format without pigment modification?

Header ("Content-type:image/gif")

$im=imagecreate (200300)

$black=ImageColorAllocate ($im,0,0,0)

$red=ImageColorAllocate ($im,255,0,0)

$blue=ImageColorAllocate ($im,0,0255)

Imagerectangle ($im,100,200,150,200,$red)

Imagestring ($im,2,120,150, "aaaaaaaa", $blue)

Imagecolortransparent ($im,$black)

/ / use black as a transparent color

ImageGif ($im)

ImageDestroy ($im)

? >

The above is the editor for you to share how to solve the dynamic generation of gif format image without pigmentation problem, if there happens to be a similar doubt, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Graphics format pigment dynamic image generation file problem same content black analysis professional small and medium code location rich content size that is article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Tech Info MariaDB macOS Redmi