Skip to content

Commit

Permalink
jpg
Browse files Browse the repository at this point in the history
  • Loading branch information
Carter Konz committed Apr 29, 2019
1 parent d1ab498 commit f7ddfd0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ server {

location ~ /api/* { try_files $uri @app; }
location ~ /static/master.png { try_files $uri @app; }
location ~ /static/master.jpg { try_files $uri @app; }
location @app {
include uwsgi_params;

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
height: 11.8%;
top: 8.7%;
left: 33.3%;
background-image: url('//youwont.bet/static/master.png');
background-image: url('//youwont.bet/static/master.jpg');
background-size: cover;
}

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class App extends Component {
<div className="background">
<div className="grid">
<div className="slot-machine-graphic">
<a className="album-art" href="https://youwont.bet/static/master.png"></a>
{/* eslint-disable-next-line jsx-a11y/anchor-has-content */}
<a className="album-art" href="//youwont.bet/static/master.jpg"></a>
<div className="reels-container">
<SlotMachine />
</div>
Expand Down
7 changes: 7 additions & 0 deletions server/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def save_copy_of_master(
source=MASTER_IMAGE_PATH,
destination="assets/images/composite/iterations",
backup=True,
jpeg=False,
):
timestamp = datetime.now().timestamp()
path_split = source.split(".")
Expand All @@ -87,6 +88,11 @@ def save_copy_of_master(
backup_path = os.path.join(destination, ts_name)
master_name = "master.png"
copy_path = os.path.join(destination, master_name)
if jpeg:
with Image(file=open(source, "rb")) as image:
image.format = 'jpeg'
image.compression_quality = 65
image.save(filename="{}/master.jpg".format(destination))
if backup:
shutil.copy(source, backup_path)
else:
Expand All @@ -112,4 +118,5 @@ def update_master_image(
source=master_path,
destination="static",
backup=False,
jpeg=True,
)
11 changes: 10 additions & 1 deletion server/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from pymongo import MongoClient
from datetime import datetime
from flask import current_app

from server.images import save_copy_of_master
from server.constants import MASTER_IMAGE_PATH

def reset_submissions():
mongo = MongoClient(os.environ["DB"])
Expand Down Expand Up @@ -33,3 +34,11 @@ def reset_submissions():
"assets/images/composite/original/master.png",
"static/master.png",
)

def create_jpg():
save_copy_of_master(
source=MASTER_IMAGE_PATH,
destination="static",
backup=False,
jpeg=True,
)

0 comments on commit f7ddfd0

Please sign in to comment.