Manav Rathi 1 vuosi sitten
vanhempi
commit
2d5ab044ee

+ 0 - 10
web/apps/photos/src/services/livePhotoService.ts

@@ -34,16 +34,6 @@ export const decodeLivePhoto = async (file: EnteFile, zipBlob: Blob) => {
     return livePhoto;
     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) => {
 export const encodeLivePhoto = async (livePhoto: LivePhoto) => {
     const zip = new JSZip();
     const zip = new JSZip();
     zip.file(
     zip.file(

+ 25 - 0
web/packages/media/live-photo.ts

@@ -20,6 +20,21 @@ export function getFileExtensionWithDot(filename: string) {
     else return filename.slice(lastDotPosition);
     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) => {
 export const decodeLivePhoto = async (fileName: string, zipBlob: Blob) => {
     const [name] = nameAndExtension(fileName);
     const [name] = nameAndExtension(fileName);
     const zip = await JSZip.loadAsync(zipBlob, { createFolders: true });
     const zip = await JSZip.loadAsync(zipBlob, { createFolders: true });
@@ -39,6 +54,16 @@ export const decodeLivePhoto = async (fileName: string, zipBlob: Blob) => {
     return livePhoto;
     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) => {
 export const encodeLivePhoto = async (livePhoto: LivePhoto) => {
     const [, imageExt] = nameAndExtension(livePhoto.imageNameTitle);
     const [, imageExt] = nameAndExtension(livePhoto.imageNameTitle);
     const [, videoExt] = nameAndExtension(livePhoto.videoNameTitle);
     const [, videoExt] = nameAndExtension(livePhoto.videoNameTitle);