Changes to make previews download faster - scale them and refresh the
url in the json
This commit is contained in:
parent
beea325ebf
commit
012bf1056f
|
@ -49,6 +49,7 @@ RUN python3 -m pip install --upgrade Pillow
|
|||
RUN apk add zip
|
||||
RUN apk add xclip
|
||||
RUN apk add curl
|
||||
RUN apk add vips
|
||||
|
||||
COPY . /opt
|
||||
CMD /opt/prepare-firefox.sh
|
||||
|
|
|
@ -20,7 +20,7 @@ if [ "$PREVIEW" = "TRUE" ];
|
|||
then
|
||||
(while true; do
|
||||
grab_screen_to_public $ID
|
||||
sleep 1
|
||||
sleep 0.7
|
||||
done) &
|
||||
refresher_pid=$!;
|
||||
fi
|
||||
|
|
|
@ -66,12 +66,17 @@ quicktype(){
|
|||
|
||||
grab_screen_to_public(){
|
||||
id=$1
|
||||
filepath="/opt/static/$id/preview.png"
|
||||
tempfile="/opt/static/$id/temp.png"
|
||||
format="jpg"
|
||||
filepath="/opt/static/$id/preview.$format"
|
||||
tempfile="/opt/static/$id/temp.$format"
|
||||
croppedfile="/opt/static/$id/temp-cropped.$format"
|
||||
scaledfile="/opt/static/$id/temp-cropped-scaled.$format"
|
||||
mkdir -p "/opt/static/$id"
|
||||
rm -f "$tempfile"
|
||||
scrot "$tempfile"
|
||||
mv -f "$tempfile" "$filepath"
|
||||
vips crop "$tempfile" "$croppedfile" 0 24 2856 1564
|
||||
vips resize "$croppedfile" "$scaledfile" 0.2
|
||||
mv -f "$scaledfile" "$filepath"
|
||||
}
|
||||
|
||||
keycombo(){
|
||||
|
|
|
@ -81,7 +81,7 @@ router.get("/", async (ctx) => {
|
|||
do {
|
||||
response = await (await fetch(\`/api/requests/\${id}\`)).json();
|
||||
output.innerHTML = JSON.stringify(response, null, " ").replace(
|
||||
/\\/(static|api)\\/.*(.png|all-screenshots)/g,
|
||||
/\\/(static|api)\\/.*(.png|all-screenshots|v=[0-9]+)/g,
|
||||
'<a href="$&">$&</a>'
|
||||
);
|
||||
stdout.innerHTML = response.output.replace(
|
||||
|
|
|
@ -90,7 +90,7 @@ export default class ScreenshotRequest {
|
|||
this.status === "finished"
|
||||
? `/api/requests/${this.id}/all-screenshots`
|
||||
: null,
|
||||
preview: `/static/${this.id}/preview.png`,
|
||||
preview: `/static/${this.id}/preview.jpg?v=${Date.now()}`,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user