diff options
| author | Bobby <[email protected]> | 2022-11-17 12:03:33 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-11-17 12:03:33 -0500 |
| commit | 7ee5ca85fc70eecc796680edee4d9cec07e4a4e8 (patch) | |
| tree | 4d7c45801fcb01a22afad19f550f9a6e8042b333 | |
| parent | 2611c4292a7ee2d0e4edc02e13f72ec2e8148642 (diff) | |
| download | thatcomputerscientist-7ee5ca85fc70eecc796680edee4d9cec07e4a4e8.tar.xz thatcomputerscientist-7ee5ca85fc70eecc796680edee4d9cec07e4a4e8.zip | |
backgorund image change and change function display color
| -rw-r--r-- | blog/views.py | 15 | ||||
| -rw-r--r-- | requirements.txt | 3 | ||||
| -rw-r--r-- | static/css/main.css | 5 | ||||
| -rw-r--r-- | static/images/site/backgound.jpeg | bin | 0 -> 152897 bytes |
4 files changed, 18 insertions, 5 deletions
diff --git a/blog/views.py b/blog/views.py index 26d75e69..e1113016 100644 --- a/blog/views.py +++ b/blog/views.py @@ -12,6 +12,8 @@ import json from .models import Post, Comment from .context_processors import recent_posts from announcements.models import Announcement +from PIL import Image +from io import BytesIO # Create your views here. @@ -178,6 +180,15 @@ def tex(request): import requests - image = requests.get('https://latex.codecogs.com/png.image?%5Cinline%20%5Clarge%20%5Cdpi%7B300%7D%5Cbg%7Bblack%7D' + expression).content + image = requests.get('https://latex.codecogs.com/png.image?%5Cinline%20%5Clarge%20%5Cdpi%7B300%7D%5Cbg%7Btransparent%7D' + expression).content - return HttpResponse(image, content_type='image/png') + # Image is a transparent GIF with black text. Invert the colors. + image = Image.open(BytesIO(image)) + image = image.convert('RGB') + image = Image.eval(image, lambda x: 255 - x) + image = image.convert('RGBA') + + # Convert back to gif and return + output = BytesIO() + image.save(output, format='GIF') + return HttpResponse(output.getvalue(), content_type='image/gif') diff --git a/requirements.txt b/requirements.txt index efee8138..47cbb152 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,5 @@ six==1.16.0 cryptocode==0.1 captcha==0.4 PyGithub==1.55 -requests==2.28.1
\ No newline at end of file +requests==2.28.1 +pillow==9.2.0
\ No newline at end of file diff --git a/static/css/main.css b/static/css/main.css index 412b2358..ba0c9d16 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -1,8 +1,9 @@ body { - background-image: url("../images/site/bg.gif"); - background-repeat: repeat; + background-image: url("../images/site/backgound.jpeg"); + background-repeat: no-repeat; background-attachment: fixed; background-position: center; + background-size: cover; font-family: 'Times New Roman', Times, serif; padding: 0; margin: 0; diff --git a/static/images/site/backgound.jpeg b/static/images/site/backgound.jpeg Binary files differnew file mode 100644 index 00000000..90281bd8 --- /dev/null +++ b/static/images/site/backgound.jpeg |
