PHP - getting a site's favicon and converting it to png if necessary

后端 未结 6 524
醉梦人生
醉梦人生 2020-12-28 22:57

For any given site \"example.domain.tld\" or merely \"domain.tld\" I need to do the following in PHP:

  • If the site has a favicon, get it wherever it is
6条回答
  •  不思量自难忘°
    2020-12-28 23:45

    If the favicon isn't located at /favicon.ico I guess you have to parse the HTML.

    For the filetype detection, you can use this extension, which detects the filetype by using magic bytes.

    You can convert to PNG by using the GD library, an example can be found here.

提交回复
热议问题