Resolve "Chunking/Thumbnailing Images"

Closes #71 (closed), #115 (closed)

  • store original image width and height in draft json as imageWidth and imageHeight (width and height could be for image as it appears in draft)
  • add options for thumbnailing images
      thumbnails?: Array<{
        /// Scale under which to show thumbnail
        scale: number;
        /// Minimum dimension for which thumbnails should be created for
        minimumImageSize: number;
        /// Target size for the smallest dimension of the thumbnail
        thumbnailSmallDimension: number;
  • If don't have imageWidth and imageHeight, download original image, then update image with width and height.
    • If image is then larger than the minimumImageSize for thumbnails, request the thumbnail.
    • Generate and cache (store) the thumbnails as required
  • Handle newly inserted images
  • Take into consideration scaling of the image in the draft handle in #98
  • Add config for enabling preloading of thumbnails and original image
  • Always take into consideration the current scale and pan to choose what thumbnail to use
  • On initial load, always choose smallest thumbnail, then select proper once have resized to fit (if enabled)
  • Load thumbnails initially
  • Load full-size image for visible images when above scale
  • Unload full-size images that are no longer visible with buffer around view
  • Unload full-size images when zoom out to under scale
  • Unload full-size images when pan off image
  • Create thumbnails using https://github.com/KnicKnic/WASM-ImageMagick sharp
  • Ensure thumbnails are removed when deleting image from draft
  • Add initial status message option to config
  • Make better upload status message (progress and collapsed)
  • Add loadsing status when changing source of image (as can be slow)
  • Add uploading status
  • Recreate thumbnails when smallThumbnailDimension changes?

Notes

  • Storing the thumbnail small dimension will mean that images like panoramas could be still very large.
  • Having multiple thumbnail sizes could be difficult to determine which one to use and may not be that helpful - implement handling only 1 thumbnail setting
  • What happens when the thumbnail settings are changed? Should all thumbnails be wiped if the thumbnailSmallDimension is different?
  • Do we want to keep the thumbnail for ever or delete after a certain period
    • Could delete when dimension changes and after a certain period - need to test how long it takes to generate the thumbnails
  • thumbs endpoint thumbs/:image, e.g. thumbs/files/:file or thumbs/:url (can then generate thumbnails for images not hosted on server)?
  • could potentially allow the specifying of a thumbnail url - probably not worth the hassle
  • generate thumbnails only when required

Existing Drafts (Migration)

When don't have a width and height, won't be able to determine if need thumbnail, so will have to load original image. Once original is loaded, can then update image details with imageWidth and imageHeight

Edited by BytesNZ

Merge request reports

Loading