Uyongeza njani i-watermark ngokukhawuleza kwaye ngobuninzi

yongeza i-watermark ngokukhawuleza kwaye ngobuninzi

Le yindlela endiyisebenzisayo ngoku yongeza ii-watermark okanye ii-watermark kwimifanekiso yeblogi. Ndidla ngokuba neefoto ezaneleyo zamanqaku kwaye ngesi sikripthi se-bash ndongeza i-watermark kwimizuzwana emi-2 okanye emi-3.

Ngexesha elidlulileyo ndasebenzisa I-GIMP yokuhlela uninzi. Olu khetho, apho sabona kwiblogi isasebenza, kodwa oku kubonakala kukhawuleza kakhulu kum kwaye njengoko ndisitsho yile nto ndiyisebenzisayo ngoku.

Le ndlela ikwafanelekile kubafoti ekufuneka bagqithise imifanekiso ephawulweyo kubathengi, kuba kwimizuzwana embalwa uye wayenza.

Ewe kunjalo, sisisombululo kubasebenzisi beLinux, ndisebenzisa Ubuntu. Ngoku ndikushiya iskripthi kunye nenkcazo yesinyathelo-nge-nyathelo ukwenzela ukuba ungayisebenzisi kuphela kodwa uqonde into eyenzayo kwaye uqale ukufunda i-BASH. Kukho imigca esi-8 kuphela.

Sebenzisa ImageMagick kufuneka uyifakele ukuba iskripthi sisebenzele wena. Vula i-terminal kunye nohlobo

sudo apt install imagemagick

Ngale nto sinokusebenzisa imisebenzi ye-ImageMagick, isityalo, ubungakanani kwakhona, ukunciphisa umzimba, ukutshintsha ifomathi, ukudibanisa imifanekiso, njl njl. Ukuba ufuna ukwazi ngakumbi yiya kwiwebhusayithi yayo esemthethweni.

I sebenza njani

Inkulumbuso GituHub ngesi script. Kusafuneka ndifunde ukuyisebenzisa kakuhle.

Isakhiwo sefayile yeskripthi se-watermark

Inkqubo endiyilungisileyo iqulathe ifayile enye, umfanekiso omnye kunye neefolda ezi-1.

Ifolda iifoto kulapho ndibeka khona imifanekiso apho ndifuna ukongeza i-watermark. Y Kwifolda Mveliso kulapho zivela khona sele zihleliwe.

I-watermark-ikkarocom.png yi-watermark endiyisebenzisayo

lovimba

Kwaye ekugqibeleni kukho .sh ifayile watermark.sh leyo equlathe ikhowudi kwi BASH

Ukuba awuqinisekanga ukuba yintoni kunye nendlela yokusebenza ngayo .sh, nantsi indawo yokuqalisa Iqhutywa njani ifayile ye.sh

Inkcazo yekhowudi inyathelo ngenyathelo.

Indlela elula yokufunda inkqubo ye-BASH kukujonga imizekelo yemibhalo esele yenziwe kunye neenkqubo. Le yikhowudi endiyisebenzisayo.

#!/bin/bash

cd photos
for pic in *; do
    composite -dissolve 90% -gravity southeast -geometry +40+30 ../watermark-ikkarocom.png $pic ${pic//.jpg}-marked.jpg
done
mv *-marked.jpg ../output
rm *

Ukuququzelela ukuqonda kwakho ndicacisa ngemigca.

#!/bin/bash

Yi-shebang, esetyenziselwa ukubonisa itoliki ukuba isebenzise ikhowudi.

cd photos

Sifaka ifolda iifoto, apho siya kube sishiye iifoto apho sifuna ukongeza i-watermark. Le nkqubo inokuthi yenziwe ngokuzenzekelayo ngokuthumela imifanekiso ngokuthe ngqo kwisiqulathi seefayili esisuka kwiselfowuni. Kodwa ndiyayiyeka.

for pic in *; do

Ukuqala kwe-loop, apho siyixelela ukuba kuzo zonke iifoto ezikwifolda, kuya kufuneka wenze imiyalelo elandelayo.

composite -dissolve 90% -gravity southeast -geometry +40+30 ../watermark-ikkarocom.png $pic ${pic//.jpg}-marked.jpg

Yinxalenye ye-ImageMagick. Sithi kwiifoto kwifolda songeza enye phezulu, kulo mzekelo "watermark-ikkarocom.png" kunye nokucaca kwi-90% okanye i-10% kuxhomekeke kwindlela ofuna ukuyijonga ngayo. Ibekwe kumzantsi-mpuma womfanekiso, oko kukuthi, ekunene ezantsi kunye nemida okanye ulwahlulo lwe-40 kunye ne-30 px ngokubhekisele kumfanekiso ongasemva.

Ukongeza kwigama lemifanekiso, yongeza isimamva esiphawulweyo. Ukuze sikwazi ukuzohlula kwezo singazihlelanga.

Apha singongeza imiyalelo engakumbi kwaye silinganise ubungakanani bomfanekiso, sinciphise ubunzima okanye siwucinezele.

Ungasebenzisa igama le-watermark oyifunayo ngokutshintsha i-watermark-ikarocom.png

done

imisela ukuba i-loop iphela phi

mv *-marked.jpg ../output

Imifanekiso ihleli kwifolda yeefoto, ke ngalo mgca sikuxelela ukuba uthathe yonke imifanekiso ngesimamva-marked.jpg kwaye uyihambise kwifolda yemveliso. Sebenzisa indlela ehambelanayo. I ../ kukunyuka ukusuka kulawulo ukuya apho imveliso ifunyenwe kwaye emva koko ungene ngaphakathi.

rm *

Ekugqibeleni, njengoko sele sinezithombe zethu kwimveliso, sisusa zonke iifayile ze-jpg ezikwiifoto.

Ukuphucula

Ngokwenza inqaku ndiye ndaqaphela uphuculo oluninzi.

  • Ndihlala ndigcina kwi-.jpg ifomathi nangona umfanekiso wegalelo uyi-.png, oku kunokuba yingxaki ukuba umfanekiso wokuqala unokufihlwa.

Shiya amazwana