Quote2Image
Quote2Image V0.5
一个将文本引号转换为图形图像的Python模块
要安装Quote2Image,您可以使用pip :
pip install Quote2ImageConvert函数采用以下参数:
quote :转换的报价。author :Quote的作者。fg :文本的前景颜色。bg :图像的背景颜色。font_type :用于文本的字体。font_size :此字体大小用于报价。font_size_author :此字体大小用于作者(可选,默认值设置为font_size )。width :图像的宽度。height :图像的高度。watermark_text :水印的文字(将其空白以无水印)。watermark_font_size :水印文本的字体大小(可选,默认保存设置为font_size )。 该软件包具有内置的GenerateColors功能,该功能以正确量的光度生成FG和BG颜色,并将其返回到元组中。
from Quote2Image import Convert , GenerateColors
# Generate Fg and Bg Color
fg , bg = GenerateColors ()
img = Convert (
quote = "Pooing keeps you healthy" ,
author = "Pee" ,
fg = fg ,
bg = bg ,
font_size = 32 ,
font_type = "arial.ttf" ,
width = 1080 ,
height = 450 )
# Save The Image as a Png file
img . save ( "hello.png" )我们可以使用ImgObject来做到这一点,这使我们对希望背景图像的方式有很多灵活性。
ImgObject类采用以下参数:
image :背景图像的链接(必需)。brightness :图像的亮度(可选,默认为100)。blur :图像的模糊(可选,默认为0)。然后,您可以将ImgObject实例用作转换函数中的bg参数:
from Quote2Image import Convert , ImgObject
bg = ImgObject ( image = "IMAGE FILE LOCATION" , brightness = 80 , blur = 80 )
img = Convert (
quote = "Pooing keeps you healthy" ,
author = "Pee" ,
fg = ( 21 , 21 , 21 ),
bg = bg ,
font_size = 32 ,
font_type = "arial.ttf" ,
width = 1080 ,
height = 450 )
# Save The Image as a Png file
img . save ( "hello.png" )watermark_text :水印的文字。watermark_font_size :水印文本的字体大小。 from Quote2Image import Convert , GenerateColors
# Generate Fg and Bg Color
fg , bg = GenerateColors ()
img = Convert (
quote = "Pooing keeps you healthy" ,
author = "Pee" ,
fg = fg ,
bg = bg ,
font_size = 32 ,
font_type = "arial.ttf" ,
font_size_author = 25 ,
width = 1080 ,
height = 450 ,
watermark_text = "@My.Watermark" ,
watermark_font_size = 15
)
# Save The Image as a Png file
img . save ( "hello.png" )谢谢你!希望这对您有用<3