Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
A
adacher
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneurs
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Elliu
adacher
Validations
e2c4fd45
Valider
e2c4fd45
rédigé
Il y a 2 ans
par
Elliu
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Support imgBase and bgCol
parent
9ff03bc0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
adacher.py
+23
-12
23 ajouts, 12 suppressions
adacher.py
avec
23 ajouts
et
12 suppressions
adacher.py
+
23
−
12
Voir le fichier @
e2c4fd45
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
argparse
import
argparse
import
math
import
math
import
tempfile
import
tempfile
import
sys
from
PIL
import
Image
from
PIL
import
Image
from
PIL
import
ImageFont
from
PIL
import
ImageFont
...
@@ -14,7 +15,7 @@ parser = argparse.ArgumentParser(
...
@@ -14,7 +15,7 @@ parser = argparse.ArgumentParser(
description
=
'
Generate beautiful adachers
'
)
description
=
'
Generate beautiful adachers
'
)
parser
.
add_argument
(
'
text
'
)
parser
.
add_argument
(
'
text
'
)
parser
.
add_argument
(
'
--imgBase
'
,
type
=
str
,
default
=
"
adachi
_white.png
"
)
parser
.
add_argument
(
'
--imgBase
'
,
type
=
str
,
default
=
"
adachi
"
)
parser
.
add_argument
(
'
--nobox
'
,
action
=
'
store_true
'
,
default
=
False
)
parser
.
add_argument
(
'
--nobox
'
,
action
=
'
store_true
'
,
default
=
False
)
parser
.
add_argument
(
'
--nowrap
'
,
action
=
'
store_true
'
,
default
=
False
)
parser
.
add_argument
(
'
--nowrap
'
,
action
=
'
store_true
'
,
default
=
False
)
parser
.
add_argument
(
'
--boxtop
'
,
type
=
float
,
default
=
0.65
)
parser
.
add_argument
(
'
--boxtop
'
,
type
=
float
,
default
=
0.65
)
...
@@ -24,12 +25,23 @@ parser.add_argument('--textHoriMargin', type=int, default=10)
...
@@ -24,12 +25,23 @@ parser.add_argument('--textHoriMargin', type=int, default=10)
parser
.
add_argument
(
'
--fontPath
'
,
type
=
str
,
default
=
"
comic.ttf
"
)
parser
.
add_argument
(
'
--fontPath
'
,
type
=
str
,
default
=
"
comic.ttf
"
)
parser
.
add_argument
(
'
--textCol
'
,
type
=
str
,
default
=
"
ff0000
"
)
parser
.
add_argument
(
'
--textCol
'
,
type
=
str
,
default
=
"
ff0000
"
)
parser
.
add_argument
(
'
--boxCol
'
,
type
=
str
,
default
=
"
ffffff
"
)
parser
.
add_argument
(
'
--boxCol
'
,
type
=
str
,
default
=
"
ffffff
"
)
parser
.
add_argument
(
'
--bgCol
'
,
type
=
str
,
default
=
"
ffffff
"
)
parser
.
add_argument
(
'
--align
'
,
type
=
str
,
default
=
"
center
"
)
parser
.
add_argument
(
'
--align
'
,
type
=
str
,
default
=
"
center
"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
args
.
imgBase
=
"
adachi_white.png
"
args
.
fontPath
=
"
comic.ttf
"
args
.
fontPath
=
"
comic.ttf
"
imgBases
=
{
"
adachi
"
:
"
adachi_white.png
"
,
"
adacher
"
:
"
adacher.png
"
}
if
(
args
.
imgBase
in
imgBases
):
args
.
imgBase
=
imgBases
[
args
.
imgBase
]
else
:
print
(
"
Wrong base image
"
)
sys
.
exit
(
1
)
withBox
=
not
args
.
nobox
withBox
=
not
args
.
nobox
withWrap
=
not
args
.
nowrap
withWrap
=
not
args
.
nowrap
...
@@ -37,6 +49,7 @@ def hexToCol(st):
...
@@ -37,6 +49,7 @@ def hexToCol(st):
return
tuple
(
int
(
st
[
i
:
i
+
2
],
16
)
for
i
in
(
0
,
2
,
4
))
return
tuple
(
int
(
st
[
i
:
i
+
2
],
16
)
for
i
in
(
0
,
2
,
4
))
textCol
=
hexToCol
(
args
.
textCol
)
textCol
=
hexToCol
(
args
.
textCol
)
boxCol
=
hexToCol
(
args
.
boxCol
)
boxCol
=
hexToCol
(
args
.
boxCol
)
bgCol
=
hexToCol
(
args
.
bgCol
)
##### Function to calculate font size and line breaks
##### Function to calculate font size and line breaks
...
@@ -89,21 +102,19 @@ def growFontToBox(draw, fontPath, text, width, height, wrap=False):
...
@@ -89,21 +102,19 @@ def growFontToBox(draw, fontPath, text, width, height, wrap=False):
return
newText
,
newSize
return
newText
,
newSize
imgBase
=
Image
.
open
(
args
.
imgBase
)
img
=
Image
.
open
(
args
.
imgBase
)
width
,
height
=
img
.
size
##### Add white box
##### Add white box
boxTop
=
args
.
boxtop
*
img
.
size
[
1
]
boxTop
=
args
.
boxtop
*
img
Base
.
size
[
1
]
boxHeight
=
args
.
boxheight
*
img
.
size
[
1
]
boxHeight
=
args
.
boxheight
*
img
Base
.
size
[
1
]
boxBot
=
math
.
floor
(
boxTop
+
boxHeight
)
boxBot
=
math
.
floor
(
boxTop
+
boxHeight
)
if
args
.
boxtop
+
args
.
boxheight
!=
1
:
tmp
=
Image
.
new
(
"
RGB
"
,
(
width
,
boxBot
))
img
=
Image
.
new
(
"
RGBA
"
,
(
imgBase
.
size
[
0
],
boxBot
))
tmp
.
paste
(
img
,
(
0
,
0
))
width
,
height
=
img
.
size
img
=
tmp
draw
=
ImageDraw
.
Draw
(
img
)
draw
=
ImageDraw
.
Draw
(
img
)
draw
.
rectangle
([
0
,
0
,
width
,
boxBot
],
bgCol
)
img
.
alpha_composite
(
imgBase
)
draw
.
rectangle
([
0
,
boxTop
,
width
,
boxBot
],
boxCol
)
draw
.
rectangle
([
0
,
boxTop
,
width
,
boxBot
],
boxCol
)
newText
,
fontsize
=
growFontToBox
(
draw
,
args
.
fontPath
,
args
.
text
,
img
.
size
[
0
]
-
2
*
args
.
textHoriMargin
,
boxHeight
-
2
*
args
.
textVertMargin
,
withWrap
)
newText
,
fontsize
=
growFontToBox
(
draw
,
args
.
fontPath
,
args
.
text
,
img
.
size
[
0
]
-
2
*
args
.
textHoriMargin
,
boxHeight
-
2
*
args
.
textVertMargin
,
withWrap
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter