diff options
| author | Bob Zeleznik <zzzman@gmail.com> | 2019-10-09 23:30:36 -0400 |
|---|---|---|
| committer | Bob Zeleznik <zzzman@gmail.com> | 2019-10-09 23:30:36 -0400 |
| commit | 5617124a794b8d256e3d24b143b8dd2403cce993 (patch) | |
| tree | 673a288cdbc853d697c2d8294312f563ae9f4e60 /src/client/util/Import & Export/ImageUtils.ts | |
| parent | 2cc7ca6b267d9dd6b1683d59b6966a021339bc18 (diff) | |
| parent | 3b1345616bf2f7101a21c182e0c9719b1e31f899 (diff) | |
merged
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 |
