mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-15 12:38:03 +00:00
Default to SVG output, but allow PNG by format parameter
This commit is contained in:
@@ -1301,6 +1301,8 @@ class AvatarView(View):
|
||||
"""
|
||||
Handle get for create view
|
||||
"""
|
||||
format = "svg+xml"
|
||||
|
||||
avatar_style = list(pa.AvatarStyle)[0]
|
||||
skin_color = list(pa.SkinColor)[0]
|
||||
hair_color = list(pa.HairColor)[0]
|
||||
@@ -1354,6 +1356,11 @@ class AvatarView(View):
|
||||
clothe_graphic_type = list(pa.ClotheGraphicType)[
|
||||
int(request.GET["clothe_graphic_type"])
|
||||
]
|
||||
if "format" in request.GET:
|
||||
if request.GET["format"] == "png":
|
||||
format = request.GET["format"]
|
||||
else:
|
||||
print("Format: '%s' isn't supported" % request.GET["format"])
|
||||
|
||||
avatar = pa.PyAvataaar(
|
||||
style=avatar_style,
|
||||
@@ -1372,4 +1379,7 @@ class AvatarView(View):
|
||||
clothe_color=clothe_color,
|
||||
clothe_graphic_type=clothe_graphic_type,
|
||||
)
|
||||
if format == "png":
|
||||
return HttpResponse(avatar.render_png(), content_type="image/png")
|
||||
|
||||
return HttpResponse(avatar.render_svg(), content_type="image/svg+xml")
|
||||
|
||||
Reference in New Issue
Block a user