Favicon generator for Python3,具有强类型同步和异步API、CLI和HTML生成。

favicons的Python项目详细描述


贫民区

Favicon generator for Python 3,具有强类型同步和异步API、CLI和HTML生成。


PyPI ^{1}$ CI

GitHub Contributors


Changelog

安装

pip3 install favicons

文件

更多文档即将到来。记住,这是一个正在进行的工作。

支持的格式

  • SVG
  • 巴布亚新几内亚
  • JPEG格式
  • 蒂芙

CLI

^{pr2}$

generate

从命令行生成favicon:

Usage: favicons generate [OPTIONS]  Generate FaviconsOptions:  --source PATH                    Source Image  [required]  --output-directory PATH          Output Directory  [required]  --background-color TEXT          Background Color  [default: #000000]  --transparent / --no-transparent Transparent Background  [default: True]  --base-url TEXT                  Base URL for HTML output  [default: /]  --help                           Show this message and exit.

html

生成HTML元素(与generate相同的选项)。在

json

生成favicon对象的JSON数组(与generate相同的选项)。在

names

生成favicon文件名列表(与generate相同的选项)。在

Python同步API

fromfaviconsimportFaviconsYOUR_ICON="/home/user/icon.jpg"WEB_SERVER_ROOT="/var/www/html"withFavicons(YOUR_ICON,WEB_SERVER_ROOT)asfavicons:favicons.generate()foriconinfavicons.filenames():print(icon)# favicon.ico# favicon-16x16.png# favicon-32x32.png# favicon-64x64.png# favicon-96x96.png# favicon-180x180.png# apple-touch-icon-57x57.png# apple-touch-icon-60x60.png# apple-touch-icon-72x72.png# apple-touch-icon-76x76.png# apple-touch-icon-114x114.png# apple-touch-icon-120x120.png# apple-touch-icon-144x144.png# apple-touch-icon-152x152.png# apple-touch-icon-167x167.png# apple-touch-icon-180x180.png# mstile-70x70.png# mstile-270x270.png# mstile-310x310.png# mstile-310x150.png# favicon-196x196.png

Python异步API

fromfaviconsimportFaviconsYOUR_ICON="/home/user/icon.jpg"WEB_SERVER_ROOT="/var/www/html"asyncwithFavicons(YOUR_ICON,WEB_SERVER_ROOT)asfavicons:awaitfavicons.generate()foriconinfavicons.filenames():print(icon)# favicon.ico# favicon-16x16.png# favicon-32x32.png# favicon-64x64.png# favicon-96x96.png# favicon-180x180.png# apple-touch-icon-57x57.png# apple-touch-icon-60x60.png# apple-touch-icon-72x72.png# apple-touch-icon-76x76.png# apple-touch-icon-114x114.png# apple-touch-icon-120x120.png# apple-touch-icon-144x144.png# apple-touch-icon-152x152.png# apple-touch-icon-167x167.png# apple-touch-icon-180x180.png# mstile-70x70.png# mstile-270x270.png# mstile-310x310.png# mstile-310x150.png# favicon-196x196.png

HTML

为每个生成的favicon获取HTML元素:

fromfaviconsimportFaviconsYOUR_ICON="/home/user/icon.jpg"WEB_SERVER_ROOT="/var/www/html"asyncwithFavicons(YOUR_ICON,WEB_SERVER_ROOT)asfavicons:awaitfavicons.generate()# As generatorhtml=favicons.html_gen()# As tuplehtml=favicons.html()print(html)# (#   '<link rel="None" type="image/ico" href="/favicon.ico" />',#   '<link rel="icon" type="image/png" href="/favicon-16x16.png" />',#   '<link rel="icon" type="image/png" href="/favicon-32x32.png" />',#   '<link rel="icon" type="image/png" href="/favicon-64x64.png" />',#   '<link rel="icon" type="image/png" href="/favicon-96x96.png" />',#   '<link rel="icon" type="image/png" href="/favicon-180x180.png" />',#   '<link rel="apple-touch-icon" type="image/png" '#   'href="/apple-touch-icon-57x57.png" />',#   '<link rel="apple-touch-icon" type="image/png" '#   'href="/apple-touch-icon-60x60.png" />',#   '<link rel="apple-touch-icon" type="image/png" '#   'href="/apple-touch-icon-72x72.png" />',#   '<link rel="apple-touch-icon" type="image/png" '#   'href="/apple-touch-icon-76x76.png" />',#   '<link rel="apple-touch-icon" type="image/png" '#   'href="/apple-touch-icon-114x114.png" />',#   '<link rel="apple-touch-icon" type="image/png" '#   'href="/apple-touch-icon-120x120.png" />',#   '<link rel="apple-touch-icon" type="image/png" '#   'href="/apple-touch-icon-144x144.png" />',#   '<link rel="apple-touch-icon" type="image/png" '#   'href="/apple-touch-icon-152x152.png" />',#   '<link rel="apple-touch-icon" type="image/png" '#   'href="/apple-touch-icon-167x167.png" />',#   '<link rel="apple-touch-icon" type="image/png" '#   'href="/apple-touch-icon-180x180.png" />',#   '<link rel="None" type="image/png" href="/mstile-70x70.png" />',#   '<link rel="None" type="image/png" href="/mstile-270x270.png" />',#   '<link rel="None" type="image/png" href="/mstile-310x310.png" />',#   '<link rel="None" type="image/png" href="/mstile-310x150.png" />',#   '<link rel="shortcut icon" type="image/png" href="/favicon-196x196.png" />'# )

元组

获取包含每个生成favicon属性的Python元组:

fromfaviconsimportFaviconsYOUR_ICON="/home/user/icon.jpg"WEB_SERVER_ROOT="/var/www/html"asyncwithFavicons(YOUR_ICON,WEB_SERVER_ROOT)asfavicons:awaitfavicons.generate()as_tuple=favicons.formats()print(as_tuple)# (#   {#     'dimensions': (64, 64),#     'image_format': 'ico',#     'prefix': 'favicon',#     'rel': None#   },#   {#     'dimensions': (16, 16),#     'image_format': 'png',#     'prefix': 'favicon',#     'rel': 'icon'#   },#   {#     'dimensions': (32, 32),#     'image_format': 'png',#     'prefix': 'favicon',#     'rel': 'icon'#   },#   {#     'dimensions': (64, 64),#     'image_format': 'png',#     'prefix': 'favicon',#     'rel': 'icon'#   },#   {#     'dimensions': (96, 96),#     'image_format': 'png',#     'prefix': 'favicon',#     'rel': 'icon'#   },#   {#     'dimensions': (180, 180),#     'image_format': 'png',#     'prefix': 'favicon',#     'rel': 'icon'#   },#   {#     'dimensions': (57, 57),#     'image_format': 'png',#     'prefix': 'apple-touch-icon',#     'rel': 'apple-touch-icon'#   },#   {#     'dimensions': (60, 60),#     'image_format': 'png',#     'prefix': 'apple-touch-icon',#     'rel': 'apple-touch-icon'#   },#   {#     'dimensions': (72, 72),#     'image_format': 'png',#     'prefix': 'apple-touch-icon',#     'rel': 'apple-touch-icon'#   },#   {#     'dimensions': (76, 76),#     'image_format': 'png',#     'prefix': 'apple-touch-icon',#     'rel': 'apple-touch-icon'#   },#   {#     'dimensions': (114, 114),#     'image_format': 'png',#     'prefix': 'apple-touch-icon',#     'rel': 'apple-touch-icon'#   },#   {#     'dimensions': (120, 120),#     'image_format': 'png',#     'prefix': 'apple-touch-icon',#     'rel': 'apple-touch-icon'#   },#   {#     'dimensions': (144, 144),#     'image_format': 'png',#     'prefix': 'apple-touch-icon',#     'rel': 'apple-touch-icon'#   },#   {#     'dimensions': (152, 152),#     'image_format': 'png',#     'prefix': 'apple-touch-icon',#     'rel': 'apple-touch-icon'#   },#   {#     'dimensions': (167, 167),#     'image_format': 'png',#     'prefix': 'apple-touch-icon',#     'rel': 'apple-touch-icon'#   },#   {#     'dimensions': (180, 180),#     'image_format': 'png',#     'prefix': 'apple-touch-icon',#     'rel': 'apple-touch-icon'#   },#   {#     'dimensions': (70, 70),#     'image_format': 'png',#     'prefix': 'mstile',#     'rel': None#   },#   {#     'dimensions': (270, 270),#     'image_format': 'png',#     'prefix': 'mstile',#     'rel': None#   },#   {#     'dimensions': (310, 310),#     'image_format': 'png',#     'prefix': 'mstile',#     'rel': None#   },#   {#     'dimensions': (310, 150),#     'image_format': 'png',#     'prefix': 'mstile',#     'rel': None#   },#   {#     'dimensions': (196, 196),#     'image_format': 'png',#     'prefix': 'favicon',#     'rel': 'shortcut icon'#   }# )

JSON

获取包含每个生成favicon属性的JSON数组:

fromfaviconsimportFaviconsYOUR_ICON="/home/user/icon.jpg"WEB_SERVER_ROOT="/var/www/html"asyncwithFavicons(YOUR_ICON,WEB_SERVER_ROOT)asfavicons:awaitfavicons.generate()as_json=favicons.json(indent=2)print(as_json)# [#   {#     "image_format": "ico",#     "dimensions": [#       64,#       64#     ],#     "prefix": "favicon",#     "rel": null#   },#   {#     "image_format": "png",#     "dimensions": [#       16,#       16#     ],#     "prefix": "favicon",#     "rel": "icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       32,#       32#     ],#     "prefix": "favicon",#     "rel": "icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       64,#       64#     ],#     "prefix": "favicon",#     "rel": "icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       96,#       96#     ],#     "prefix": "favicon",#     "rel": "icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       180,#       180#     ],#     "prefix": "favicon",#     "rel": "icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       57,#       57#     ],#     "prefix": "apple-touch-icon",#     "rel": "apple-touch-icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       60,#       60#     ],#     "prefix": "apple-touch-icon",#     "rel": "apple-touch-icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       72,#       72#     ],#     "prefix": "apple-touch-icon",#     "rel": "apple-touch-icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       76,#       76#     ],#     "prefix": "apple-touch-icon",#     "rel": "apple-touch-icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       114,#       114#     ],#     "prefix": "apple-touch-icon",#     "rel": "apple-touch-icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       120,#       120#     ],#     "prefix": "apple-touch-icon",#     "rel": "apple-touch-icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       144,#       144#     ],#     "prefix": "apple-touch-icon",#     "rel": "apple-touch-icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       152,#       152#     ],#     "prefix": "apple-touch-icon",#     "rel": "apple-touch-icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       167,#       167#     ],#     "prefix": "apple-touch-icon",#     "rel": "apple-touch-icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       180,#       180#     ],#     "prefix": "apple-touch-icon",#     "rel": "apple-touch-icon"#   },#   {#     "image_format": "png",#     "dimensions": [#       70,#       70#     ],#     "prefix": "mstile",#     "rel": null#   },#   {#     "image_format": "png",#     "dimensions": [#       270,#       270#     ],#     "prefix": "mstile",#     "rel": null#   },#   {#     "image_format": "png",#     "dimensions": [#       310,#       310#     ],#     "prefix": "mstile",#     "rel": null#   },#   {#     "image_format": "png",#     "dimensions": [#       310,#       150#     ],#     "prefix": "mstile",#     "rel": null#   },#   {#     "image_format": "png",#     "dimensions": [#       196,#       196#     ],#     "prefix": "favicon",#     "rel": "shortcut icon"#   }# ]

许可证

Clear BSD License

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java我试图使用@OneToOne作为双向映射来映射实体,但却遇到了奇怪的异常   性能Java异步如何工作?异步方法似乎不是异步运行的   java这个代码可以更短吗   线程“main”Java中的csv Java ArrayList异常。lang.NegativeArraySizeException:28   java确定LayoutManager预布局中的显示视图   java如何在FirestorePagingAdapter中通过方法onLoadingStateChanged隐藏/显示进度条?   在Java中,如何打印一个类似于中间有“过道”的座位表的2d数组?   http Java实现字节范围服务,而不使用仅使用Java api的servlet   java无法使用命名根元素生成json   java如何在注销侦听器中获取http会话id?   数组内部输入(java)?   java如何为特殊情况提供更简单的构造函数   java在swing应用程序中显示JavaFX后台   java如何启用系统。出来在eclipse中运行Junit测试时使用println()?   如何在Java中实现Oracle用户定义的聚合函数