bigger == better

This commit is contained in:
Aaron Gutierrez
2022-01-23 18:38:47 -08:00
parent 301d712763
commit 57d1451579
4 changed files with 9 additions and 6 deletions

View File

@@ -24,6 +24,7 @@ for f in original/*.jpg; do
done done
for img in *.jpg; do for img in *.jpg; do
make_jpg $img 2400
make_jpg $img 1600 make_jpg $img 1600
make_jpg $img 1200 make_jpg $img 1200
make_jpg $img 800 make_jpg $img 800
@@ -31,6 +32,7 @@ for img in *.jpg; do
make_jpg $img 400 make_jpg $img 400
make_jpg $img 200 make_jpg $img 200
make_webp $img 2400
make_webp $img 1600 make_webp $img 1600
make_webp $img 1200 make_webp $img 1200
make_webp $img 800 make_webp $img 800

1
pub.py
View File

@@ -145,6 +145,7 @@ def upload_images():
upload_thumbnail(800) upload_thumbnail(800)
upload_thumbnail(1200) upload_thumbnail(1200)
upload_thumbnail(1600) upload_thumbnail(1600)
upload_thumbnail(2400)
upload_file('img/data.json') upload_file('img/data.json')

View File

@@ -61,8 +61,8 @@ export class Picture extends React.PureComponent<Props, State> {
private _srcset = (): SrcSetInfo => { private _srcset = (): SrcSetInfo => {
const jpegSrcSet: string[] = []; const jpegSrcSet: string[] = [];
const webpSrcSet: string[] = []; const webpSrcSet: string[] = [];
let bestSize = 1600; let bestSize = 800;
let bestRatio = Infinity; let bestScale = Infinity;
Model.SIZES.forEach(size => { Model.SIZES.forEach(size => {
const width = const width =
@@ -72,14 +72,14 @@ export class Picture extends React.PureComponent<Props, State> {
const scale = width / this.props.width; const scale = width / this.props.width;
if (scale >= 1) { if (scale >= 1 || size === 2400) {
const jpeg = `img/${size}/${this.props.image.src}`; const jpeg = `img/${size}/${this.props.image.src}`;
const webp = jpeg.replace("jpg", "webp"); const webp = jpeg.replace("jpg", "webp");
jpegSrcSet.push(`${jpeg} ${scale}x`); jpegSrcSet.push(`${jpeg} ${scale}x`);
webpSrcSet.push(`${webp} ${scale}x`); webpSrcSet.push(`${webp} ${scale}x`);
if (scale < bestRatio) { if (scale < bestScale) {
bestSize = size; bestSize = size;
bestRatio = scale; bestScale = scale;
} }
} }
}); });

View File

@@ -1,4 +1,4 @@
export const SIZES = [1600, 1200, 800, 600, 400, 200]; export const SIZES = [2400, 1600, 1200, 800, 600, 400, 200];
export const dataUrl = "img/data.json"; export const dataUrl = "img/data.json";