[英]In python, how would I open a PIL or Imagemagick Image as a file
[英]Python PIL/imagemagick merge gradient over the base image
我已經知道如何獲取漸變圖像,但是如何合並漸變圖像和基礎圖像,使其看起來像這樣: link
convert -size 1327x1327 xc:transparent gradient: grad_image.png
或在這里建議了另一種方法基本圖像是 輸出應該像下面這樣在底部漸變: https : //1drv.ms/i/s!Aoi-6MWkMNN4kGLYNmqN9dm1nrOD
我只能猜測您要做什么,所以我的第一個嘗試是:
convert jelly.jpg \( -size 1140x100! gradient:none-black \) -gravity south -composite -pointsize 36 -fill white -annotate +0+20 "Title Treatment" result.png
重要的部分是漸變是從黑色到透明,而不是從黑色到白色 ,否則您的背景會變成白色 ,我猜這是您不想要的。
-gravity south
將漸變放置在底部,並且還設置了標題的初始位置,但是隨后使用-annotate +0+20
從底部向上移動了20個像素。
希望能有所幫助。
更新1
如果要控制漸變,可以使用rgb()
常量更改其開始和結束,如下所示:
convert jelly.jpg \( -size 1140x100! gradient:"rgba(0,0,0,0.25)"-"rgb(50,50,50)" \) -gravity south -composite -pointsize 36 -fill white -annotate +0+20 "Title Treatment" result.png
或者,您可以使其從一種顏色變為另一種顏色:
convert jelly.jpg \( -size 1140x100! gradient:"rgba(0,0,0,0.25)"-"rgba(255,255,0,0.75)" \) -gravity south -composite -pointsize 36 -fill white -annotate +0+20 "Title Treatment" result.png
或者您可以更改混合模式,因此在這里我使用colorBurn
:
convert jelly.jpg \( -size 1140x100! gradient:"rgba(0,0,0,0.25)"-"rgba(255,255,0,0.75)" \) -gravity south -compose colorburn -composite -pointsize 36 -fill white -annotate +0+20 "Title Treatment" result.png
如果您想嘗試其他混合模式,則可以使用以下列表:
identify -list compose:
Atop
Blend
Blur
Bumpmap
ChangeMask
Clear
ColorBurn
ColorDodge
Colorize
CopyAlpha
CopyBlack
CopyBlue
CopyCyan
CopyGreen
Copy
CopyMagenta
CopyRed
CopyYellow
Darken
DarkenIntensity
DivideDst
DivideSrc
Dst
Difference
Displace
Dissolve
Distort
DstAtop
DstIn
DstOut
DstOver
Exclusion
HardLight
HardMix
Hue
In
Intensity
Lighten
LightenIntensity
LinearBurn
LinearDodge
LinearLight
Luminize
Mathematics
MinusDst
MinusSrc
Modulate
ModulusAdd
ModulusSubtract
Multiply
None
Out
Overlay
Over
PegtopLight
PinLight
Plus
Replace
Saturate
Screen
SoftLight
Src
SrcAtop
SrcIn
SrcOut
SrcOver
VividLight
Xor
更新2
如果要使文本模糊,則首先創建文本,對其進行模糊處理,然后再像這樣對背景進行底襯變得更容易:
convert -size 1140x100! gradient:none-black \
-pointsize 36 -fill white -gravity south \
-annotate +5+25 "Title Treatment" -blur 0x4 \
-annotate +0+20 "Title Treatment" jelly.jpg +swap -composite result.png
更新3
如果要陰影化文本,控制漸變並執行其他操作,則一次執行一項操作可能會更好。 因此,讓我們先嘗試使用陰影創建文本,然后在圖像上放置漸變,然后在陰影文本上放置陰影-希望我們越來越近了!
string="Funky Main Title\nSub-title"
convert -size 1200x400 xc:none -pointsize 72 -gravity center \
-fill white -stroke black -annotate +25+65 "$string" \
\( +clone -background black -shadow 70x4+5+5 \) +swap \
-background none -flatten -trim +repage shadowed.png
現在在主圖像和標題上方放置漸變:
convert jelly.jpg \
\( -size 1140x100! gradient:"rgba(0,0,0,0.25)"-"rgb(50,50,50)" \) \
-gravity south -composite \
shadowed.png -composite result.png
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.