diff --git a/cli.py b/cli.py index 252b4990d7932f0ac726ace48e3408cb05c0df0d..bab25548b298e676bd4f8fa778072645face26cc 100644 --- a/cli.py +++ b/cli.py @@ -26,8 +26,8 @@ def init_db(): @click.command(name="users:add", help="Add a new user") -@click.option("user", help="Username to add", required=True) @click.option("--password", "-p", help="Password for the user", required=False) +@click.argument("user", required=True) def add_user(user: str, password: str or None): config = Config() diff --git a/picview/files.py b/picview/files.py index 0391fbdaa47bb82c77f86fc333ab89ec0bea2315..9bb081f0948dc73f0bb6d8c18542756c999c38d8 100644 --- a/picview/files.py +++ b/picview/files.py @@ -55,6 +55,11 @@ class PicturesDirectory: k.replace("EXIF", "").strip(): v for k, v in exifread.process_file(fp, details=False).items() } + + if "DateTimeOriginal" not in tags: + print(f" /!\\ Cannot parse {f.name}, missing DateTimeOriginal") + continue + print(f"{f.name}: PARSING") im = cv2.imread(f) height, width, _ = im.shape @@ -64,15 +69,16 @@ class PicturesDirectory: cdate=datetime.strptime( str(tags["DateTimeOriginal"]), "%Y:%m:%d %H:%M:%S" ), - camera=str(tags["Image Model"]), - maker=str(tags["Image Make"]), - exposure=str(tags["ExposureTime"]), - aperture=eval(str(tags["FNumber"])), - iso=int(str(tags["ISOSpeedRatings"])), - focal=eval(str(tags["FocalLength"])), + camera=str(tags.get("Image Model", "")), + maker=str(tags.get("Image Make", "")), + exposure=str(tags.get("ExposureTime", "")), + aperture=eval(str(tags.get("FNumber", "0"))), + iso=int(str(tags.get("ISOSpeedRatings", "0"))), + focal=eval(str(tags.get("FocalLength", "0"))), flash=( False - if "Flash did not fire" in str(tags["Flash"]) + if "Flash did not fire" + in str(tags.get("Flash", "Flash did not fire")) else True ), height=height, diff --git a/src/components/PictureInfoModal.js b/src/components/PictureInfoModal.js index ae2e2b9f71d259a1248e64d865076d5ad8b9889d..01a5882c7acb0c8efb56db51c1473e86b5e71eb4 100644 --- a/src/components/PictureInfoModal.js +++ b/src/components/PictureInfoModal.js @@ -9,6 +9,7 @@ import ListItem from "@mui/material/ListItem"; import ListItemText from "@mui/material/ListItemText"; import ListItemAvatar from "@mui/material/ListItemAvatar"; import Avatar from "@mui/material/Avatar"; +import ImageListItem from "@mui/material/ImageListItem"; import CameraAltIcon from "@mui/icons-material/CameraAlt"; import CalendarMonthIcon from "@mui/icons-material/CalendarMonth"; @@ -53,32 +54,52 @@ export default function PictureInfoModal({ open, setOpen, picture, blobUrl }) { </Stack> <Stack> - <Avatar - alt={picture.name} - src={blobUrl} - sx={{ width: 150, height: 150 }} - variant="rounded" - /> + <Card + sx={{ + height: "50%", + width: "50%", + mx: 0, + my: 0, + }} + > + <ImageListItem key={picture.id}> + <img src={blobUrl} alt={picture.name} loading="lazy" /> + </ImageListItem> + </Card> <List> {renderListItem( <CameraAltIcon />, "Camera", - `${picture.maker} ${picture.camera}`, + `${picture.maker}${picture.camera}` + ? `${picture.maker} ${picture.camera}` + : "no data", )} {renderListItem( <CalendarMonthIcon />, "Date", humanDateTime(new Date(picture.cdate), "fr-FR"), )} - {renderListItem(<ExposureIcon />, "Exposure", picture.exposure)} + {renderListItem( + <ExposureIcon />, + "Exposure", + picture.exposure ? picture.exposure : "no data", + )} {renderListItem( <CameraIcon />, "Aperture", - `f/${picture.aperture}`, + picture.aperture ? `f/${picture.aperture}` : "no data", + )} + {renderListItem( + <IsoIcon />, + "ISO", + picture.iso ? picture.iso : "no data", + )} + {renderListItem( + <IsoIcon />, + "Focal", + picture.focal ? `${picture.focal}mm` : "no data", )} - {renderListItem(<IsoIcon />, "ISO", picture.iso)} - {renderListItem(<IsoIcon />, "Focal", `${picture.focal}mm`)} {renderListItem( picture.flash ? <FlashOnIcon /> : <FlashOffIcon />, `Flash ${picture.flash ? "on" : "off"}`, diff --git a/src/components/Thumbnail.js b/src/components/Thumbnail.js index 150762b1968836f73896a72e008a1988ebe5fbe9..93972e0a0fce5c8c48f262504295ab980107c9f3 100644 --- a/src/components/Thumbnail.js +++ b/src/components/Thumbnail.js @@ -89,7 +89,7 @@ export default function Thumbnail({ sx={{ maxWidth: screenSize === "small" ? "auto" : 350, height: "100%", - width: screenSize === "small" ? "100%" : "auto", + width: "100%", mx: screenSize === "small" ? 0 : 1, my: 1, }}