简体   繁体   English

php gd图像类型

[英]php gd image type

I'm currently teaching myself PHP's GD library, and I have a question about image types. 我目前正在自学PHP的GD库,并且对图像类型有疑问。 Do certain GD functions only apply to certain image types, like jpegs for example? 某些GD功能是否仅适用于某些图像类型,例如jpeg? I'm not very knowledgeable about image types. 我对图像类型不是很了解。 I am wanting to learn their differences and if I should be a little more careful about the functions I'm using or am I just overthinking this stuff too much? 我想了解它们之间的差异,并且如果我应该对自己使用的功能更加小心一点,还是只是我对这些东西的想法太多了?

In memory, an image is just plain bitmap data. 在内存中,图像只是普通的位图数据。 The only time an image type becomes involved is when loading an image from a file (it has to know what type so that it can decode it into an in-memory bitmap) and when writing the file to disk (same thing, in reverse). 涉及图像类型的唯一时间是从文件加载图像时(它必须知道哪种类型,以便它可以将其解码为内存中的位图),以及何时将文件写入磁盘(反之亦然)。 。

Only the imagecreatefrom...() and the converse "save" functions are format-specific. 只有imagecreatefrom...()和相反的“保存”功能是特定于格式的。 Once loaded, they're in a gd-specific internal format. 加载后,它们将采用特定于gd的内部格式。

That being said, some GD functions don't make sense in certain contexts. 话虽如此,某些GD功能在某些情况下没有意义。 eg JPEG images don't support transparency, so specifying an alpha channel on an image that'll be saved to .jpg isn't very useful. 例如JPEG图像不支持透明性,因此在图像上指定要保存为.jpg的Alpha通道不是很有用。 But internally within GD, alpha-involved operations will still function as normal. 但是在GD内部,涉及alpha的操作仍将正常运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM