Commit 770b4612 authored by dns2utf8's avatar dns2utf8

Keep ratio during resize

parent a23841b1
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.6, maximum-scale=2.0, user-scalable=yes"/>
<title>Distributed Gallery</title>
<link rel="stylesheet" href="style.css"/>
<script src="main.js"></script>
......
......@@ -145,9 +145,9 @@ function regenPreview() {
function try_thumb(target_size, original, file_handler) {
const img = new Image();
img.onload = function() {
console.log("resize to "+target_size);
const width = Math.min(target_size, img.naturalWidth);
const height = Math.min(target_size, img.naturalHeight);
const scaleFactor = width / img.naturalWidth;
const height = scaleFactor * img.naturalHeight;
console.log([width, height]);
const canvas = document.createElement("canvas")
, ctx = canvas.getContext("2d");
......@@ -162,12 +162,10 @@ function regenPreview() {
if (blob.length > MAX_BLOB_LENGTH) {
target_size /= 2;
try_thumb(target_size, original, file_handler);
console.log("retry");
} else {
aImg.src = blob;
// backup into RAM
file_handler.blob = blob;
console.log("hurray compressed");
}
};
img.src = original;
......@@ -180,7 +178,6 @@ function regenPreview() {
try_thumb(target_size, original, file_handler);
} else {
console.log("no resize");
aImg.src = original;
// backup into RAM
file_handler.blob = original;
......
......@@ -15,7 +15,7 @@
#galleries ul li:active { background: rgba(255, 128, 128, 0.3); }
#galleries div { display: flex; flex-flow: row wrap; }
#galleries div div { display: flex; flex-flow: column nowrap; }
#galleries div div { display: flex; flex-flow: column nowrap; margin: 0.5rem; border-radius: 1rem; padding: 0.5rem; }
.selected { background: yellow; }
......
......@@ -73,7 +73,7 @@ Hello my name is Stefan and I work on and with computers.
I organize
\begin{itemize}
\item RustFest.eu Next: probably in September 2019 with "impl days" before or after the conference
\item RustFest.eu Barcelona: probably in November 2019 with "impl days" before or after
\item Meetups in and around Zürich, CH
\item ErnstEisprung.ch (a svájci Alpokban 2019 júliusában)
\end{itemize}
......@@ -84,6 +84,10 @@ Some of my side projects
\item Son of Grid Engine (SGE) interface
\item run your own infrastructure - DNS, VPN, Web, ...
\end{itemize}
Latest T-Shirt idea: Aufklären statt Aufregen => Enlighten instead of upset
Or more catchy: uplift instead of upset
\end{frame}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment