diff --git a/web/apps/photos/src/services/livePhotoService.ts b/web/apps/photos/src/services/livePhotoService.ts index 2fa11c2ca8..a4fa32de82 100644 --- a/web/apps/photos/src/services/livePhotoService.ts +++ b/web/apps/photos/src/services/livePhotoService.ts @@ -34,16 +34,6 @@ export const decodeLivePhoto = async (file: EnteFile, zipBlob: Blob) => { return livePhoto; }; -/** - * Return a binary serialized representation of a live photo. - * - * This function takes the (in-memory) image and video data from the - * {@link livePhoto} object, writes them to a zip file (using the respective - * filenames), and returns the {@link Uint8Array} that represent the bytes of - * this zip file. - * - * @param livePhoto The in-mem photo to serialized. - */ export const encodeLivePhoto = async (livePhoto: LivePhoto) => { const zip = new JSZip(); zip.file( diff --git a/web/packages/media/live-photo.ts b/web/packages/media/live-photo.ts index c5c1566e30..755bb40be8 100644 --- a/web/packages/media/live-photo.ts +++ b/web/packages/media/live-photo.ts @@ -20,6 +20,21 @@ export function getFileExtensionWithDot(filename: string) { else return filename.slice(lastDotPosition); } +/** + * Convert a binary serialized representation of a live photo to an in-memory + * {@link LivePhoto}. + * + * A live photo is a zip file containing two files - an image and a video. This + * functions reads that zip file (blob), and return separate bytes (and + * filenames) for the image and video parts. + * + * @param fileName The name of the overall live photo. Both the image and video + * parts of the decompressed live photo use this as their name, combined with + * their original extensions. + * + * @param zipBlob A blob contained the zipped data (i.e. the binary serialized + * live photo). + */ export const decodeLivePhoto = async (fileName: string, zipBlob: Blob) => { const [name] = nameAndExtension(fileName); const zip = await JSZip.loadAsync(zipBlob, { createFolders: true }); @@ -39,6 +54,16 @@ export const decodeLivePhoto = async (fileName: string, zipBlob: Blob) => { return livePhoto; }; +/** + * Return a binary serialized representation of a live photo. + * + * This function takes the (in-memory) image and video data from the + * {@link livePhoto} object, writes them to a zip file (using the respective + * filenames), and returns the {@link Uint8Array} that represent the bytes of + * this zip file. + * + * @param livePhoto The in-mem photo to serialized. + */ export const encodeLivePhoto = async (livePhoto: LivePhoto) => { const [, imageExt] = nameAndExtension(livePhoto.imageNameTitle); const [, videoExt] = nameAndExtension(livePhoto.videoNameTitle);