diff options
| author | kimdahey <claire_kim1@brown.edu> | 2019-11-03 17:07:18 -0500 |
|---|---|---|
| committer | kimdahey <claire_kim1@brown.edu> | 2019-11-03 17:07:18 -0500 |
| commit | b1e9619a4e04a9784d927c766361d734f549d6c5 (patch) | |
| tree | 36b875ccc0c45c3706d2533c4c28cc1492b38ce5 /src/client/util/Import & Export/ImageUtils.ts | |
| parent | b2777f92b50f926357ad9b595c7907368b996fbd (diff) | |
| parent | 2786a2e4b33ff874f320697b89fecec3105df201 (diff) | |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into webcam_mohammad
Diffstat (limited to 'src/client/util/Import & Export/ImageUtils.ts')
| -rw-r--r-- | src/client/util/Import & Export/ImageUtils.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/client/util/Import & Export/ImageUtils.ts b/src/client/util/Import & Export/ImageUtils.ts new file mode 100644 index 000000000..c9abf38fa --- /dev/null +++ b/src/client/util/Import & Export/ImageUtils.ts @@ -0,0 +1,31 @@ +import { Doc, DocListCast, DocListCastAsync, Opt } from "../../../new_fields/Doc"; +import { ImageField } from "../../../new_fields/URLField"; +import { Cast, StrCast } from "../../../new_fields/Types"; +import { RouteStore } from "../../../server/RouteStore"; +import { Docs } from "../../documents/Documents"; +import { Identified } from "../../Network"; +import { Id } from "../../../new_fields/FieldSymbols"; +import { Utils } from "../../../Utils"; + +export namespace ImageUtils { + + export const ExtractExif = async (document: Doc): Promise<boolean> => { + const field = Cast(document.data, ImageField); + if (!field) { + return false; + } + const source = field.url.href; + const response = await Identified.PostToServer(RouteStore.inspectImage, { source }); + const { error, data } = response.exifData; + document.exif = error || Docs.Get.DocumentHierarchyFromJson(data); + return data !== undefined; + }; + + export const ExportHierarchyToFileSystem = async (collection: Doc): Promise<void> => { + const a = document.createElement("a"); + a.href = Utils.prepend(`${RouteStore.imageHierarchyExport}/${collection[Id]}`); + a.download = `Dash Export [${StrCast(collection.title)}].zip`; + a.click(); + }; + +}
\ No newline at end of file |
