Skip to content

Commit

Permalink
make init zoom factors
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleawayan committed Feb 12, 2021
1 parent 360a132 commit aaa62da
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions components/AlbumArt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ export default function AlbumArt() {
const binaryStr = reader.result;
setImageBase64(binaryStr);
getResolution(binaryStr).then((res) => {
if (res.width !== res.height) {
setZoom(res.width / photoRef.current.clientHeight / 2.2);
if (res.width < res.height) {
// potrait photos, found in my tests that a zoom factor of about 1.5 fills the square
setZoom(1.5);
} else if (res.width > res.height) {
// landscape photos, found in my tests that a zoom factor of about 2.0 fills the square
setZoom(2.0);
} else {
setZoom(1.05); // set a little zoomed in for square photos so blank space doesn't show
// set a little zoomed in for square photos so blank space doesn't show
setZoom(1.05);
}
});
};
Expand All @@ -56,6 +61,8 @@ export default function AlbumArt() {
accept: "image/jpeg, image/png",
});

console.log(zoom);

return (
<div className={styles.palette}>
<img src="frame.png" className={styles.frame}></img>
Expand Down

0 comments on commit aaa62da

Please sign in to comment.