Flip image libraries due to white bar bug
This commit is contained in:
parent
1e4569dfbf
commit
21fe5c419a
60
Dockerfile
60
Dockerfile
@ -3,37 +3,39 @@ FROM tiangolo/uvicorn-gunicorn-fastapi:latest
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Chrome dependency Instalation
|
||||
RUN apt-get update && apt-get install -y \
|
||||
fonts-liberation \
|
||||
libasound2 \
|
||||
libatk-bridge2.0-0 \
|
||||
libatk1.0-0 \
|
||||
libatspi2.0-0 \
|
||||
libcups2 \
|
||||
libdbus-1-3 \
|
||||
libdrm2 \
|
||||
libgbm1 \
|
||||
libgtk-3-0 \
|
||||
# libgtk-4-1 \
|
||||
libnspr4 \
|
||||
libnss3 \
|
||||
libwayland-client0 \
|
||||
libxcomposite1 \
|
||||
libxdamage1 \
|
||||
libxfixes3 \
|
||||
libxkbcommon0 \
|
||||
libxrandr2 \
|
||||
xdg-utils \
|
||||
libu2f-udev \
|
||||
libvulkan1
|
||||
# Chrome instalation
|
||||
RUN curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
||||
RUN apt-get install -y ./google-chrome-stable_current_amd64.deb
|
||||
RUN rm google-chrome-stable_current_amd64.deb
|
||||
# Check chrome version
|
||||
RUN echo "Chrome: " && google-chrome --version
|
||||
# RUN apt-get update && apt-get install -y \
|
||||
# fonts-liberation \
|
||||
# libasound2 \
|
||||
# libatk-bridge2.0-0 \
|
||||
# libatk1.0-0 \
|
||||
# libatspi2.0-0 \
|
||||
# libcups2 \
|
||||
# libdbus-1-3 \
|
||||
# libdrm2 \
|
||||
# libgbm1 \
|
||||
# libgtk-3-0 \
|
||||
# # libgtk-4-1 \
|
||||
# libnspr4 \
|
||||
# libnss3 \
|
||||
# libwayland-client0 \
|
||||
# libxcomposite1 \
|
||||
# libxdamage1 \
|
||||
# libxfixes3 \
|
||||
# libxkbcommon0 \
|
||||
# libxrandr2 \
|
||||
# xdg-utils \
|
||||
# libu2f-udev \
|
||||
# libvulkan1
|
||||
# # Chrome instalation
|
||||
# RUN curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
||||
# RUN apt-get install -y ./google-chrome-stable_current_amd64.deb
|
||||
# RUN rm google-chrome-stable_current_amd64.deb
|
||||
# # Check chrome version
|
||||
# RUN echo "Chrome: " && google-chrome --version
|
||||
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
RUN playwright install
|
||||
RUN playwright install-deps
|
||||
|
||||
COPY ./app /app/app
|
||||
@ -37,7 +37,7 @@ CARDSETS = {
|
||||
},
|
||||
'minor-league': {
|
||||
'primary': [20, 8], # 1998, Mario
|
||||
'secondary': [6], # 2008
|
||||
'secondary': [6], # 2013
|
||||
'human': [x for x in range(1, 30)]
|
||||
},
|
||||
'major-league': {
|
||||
|
||||
@ -11,6 +11,7 @@ from typing import Optional, List, Literal
|
||||
import logging
|
||||
import pydantic
|
||||
from pandas import DataFrame
|
||||
from playwright.async_api import async_playwright
|
||||
|
||||
from ..card_creation import get_batter_card_data, get_pitcher_card_data
|
||||
from ..db_engine import db, Player, model_to_dict, fn, chunked, Paperdex, Cardset, Rarity, BattingCard, \
|
||||
@ -451,23 +452,31 @@ async def get_batter_card(
|
||||
).execute()
|
||||
|
||||
logging.debug(f'Rating updates: {updates}')
|
||||
|
||||
hti = Html2Image(
|
||||
browser='chromium',
|
||||
size=(1200, 600),
|
||||
output_path=f'storage/cards/cardset-{this_player.cardset.id}/{card_type}/',
|
||||
custom_flags=['--no-sandbox', '--disable-remote-debugging', '--headless', '--disable-gpu',
|
||||
'--disable-software-rasterizer', '--disable-dev-shm-usage']
|
||||
)
|
||||
|
||||
logging.debug(f'body:\n{html_response.body.decode("UTF-8")}')
|
||||
x = hti.screenshot(
|
||||
html_str=str(html_response.body.decode("UTF-8")),
|
||||
save_as=f'{player_id}-{d}-v{variant}.png'
|
||||
)
|
||||
|
||||
file_path = f'storage/cards/cardset-{this_player.cardset.id}/{card_type}/{player_id}-{d}-v{variant}.png'
|
||||
async with async_playwright() as p:
|
||||
browser = await p.chromium.launch()
|
||||
page = await browser.new_page()
|
||||
await page.set_content(html_response.body.decode("UTF-8"))
|
||||
await page.screenshot(path=file_path, type='png', clip={'x': 0.0, 'y': 0, 'width': 1200, 'height': 600})
|
||||
await browser.close()
|
||||
|
||||
# hti = Html2Image(
|
||||
# browser='chrome',
|
||||
# size=(1200, 600),
|
||||
# output_path=f'storage/cards/cardset-{this_player.cardset.id}/{card_type}/',
|
||||
# custom_flags=['--no-sandbox', '--disable-remote-debugging', '--headless', '--disable-gpu',
|
||||
# '--disable-software-rasterizer', '--disable-dev-shm-usage']
|
||||
# )
|
||||
|
||||
# x = hti.screenshot(
|
||||
# html_str=str(html_response.body.decode("UTF-8")),
|
||||
# save_as=f'{player_id}-{d}-v{variant}.png'
|
||||
# )
|
||||
|
||||
db.close()
|
||||
return FileResponse(path=x[0], media_type='image/png', headers=headers)
|
||||
return FileResponse(path=file_path, media_type='image/png', headers=headers)
|
||||
|
||||
|
||||
# @router.get('/{player_id}/pitchingcard')
|
||||
|
||||
@ -519,7 +519,7 @@ async def get_team_sp(
|
||||
db.close()
|
||||
raise HTTPException(status_code=400, detail=f'Difficulty name {difficulty_name} not a valid check')
|
||||
|
||||
all_players = Player.select().where(Player.mlbclub == this_team.lname)
|
||||
all_players = Player.select().where(Player.franchise == this_team.lname)
|
||||
|
||||
if difficulty_name == 'exhibition':
|
||||
logging.info(f'pulling an exhibition lineup')
|
||||
@ -619,7 +619,7 @@ async def get_team_rp(
|
||||
raise HTTPException(status_code=400, detail=f'Difficulty name {difficulty_name} not a valid check')
|
||||
|
||||
all_players = Player.select().where(
|
||||
(Player.mlbclub == this_team.lname) & (Player.player_id.not_in(used_pitcher_ids))
|
||||
(Player.franchise == this_team.lname) & (Player.player_id.not_in(used_pitcher_ids))
|
||||
)
|
||||
|
||||
if difficulty_name == 'exhibition':
|
||||
|
||||
@ -10,3 +10,4 @@ python-multipart
|
||||
requests
|
||||
html2image
|
||||
jinja2
|
||||
playwright
|
||||
|
||||
Loading…
Reference in New Issue
Block a user