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