ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

28 lines
835 B

  1. import { CONFIG } from '@server/initializers/config.js'
  2. import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants.js'
  3. import { ActorImageModel } from '@server/models/actor/actor-image.js'
  4. import { MActorImage } from '@server/types/models/index.js'
  5. import { AbstractPermanentFileCache } from './shared/index.js'
  6. export class AvatarPermanentFileCache extends AbstractPermanentFileCache<MActorImage> {
  7. constructor () {
  8. super(CONFIG.STORAGE.ACTOR_IMAGES_DIR)
  9. }
  10. protected loadModel (filename: string) {
  11. return ActorImageModel.loadByFilename(filename)
  12. }
  13. protected getImageSize (image: MActorImage): { width: number, height: number } {
  14. if (image.width && image.height) {
  15. return {
  16. height: image.height,
  17. width: image.width
  18. }
  19. }
  20. return ACTOR_IMAGES_SIZE[image.type][0]
  21. }
  22. }