new-horizons/docs/lib/Content/ImageStaticItem.py
Ben C 922eadb221
Updated Docs (#61)
* Add Bootstrap Extension

* Rename main.yml

* Artifact Upload

* Fix Bootstrap Reference Error

* BootstrapTreeProcessor

* getiterator removed

* keys function

* Style Images

* Update docs_build.yml

* Added Meta Files

* Template Get

* Fix Page Ref

* Update BASE_URL

* Sort Schemas

* Add Sitemaps

* Add favicons, open-graph, and setup guide

* Update Setup.md

* Update .gitignore

* Update Setup.md

* Use _blank on external links

* Restructured Docs

* Fix Links

* Added XML Schemas

* Name XML Schemas

* Improved Best Practices

* Add Logs For Static Files

* Make docs build happen on PR
2022-03-06 22:40:55 -08:00

22 lines
486 B
Python

from pathlib import Path
from PIL import Image
from lib.Content.StaticItem import StaticItem
class ImageStaticItem(StaticItem):
extensions = ('png', 'jpg', 'jpeg', 'webp')
sizes = {}
@classmethod
def get_size(cls, stem):
return cls.sizes.get(stem, (0, 0))
def __init__(self, path: Path):
super().__init__(path)
with Image.open(self.in_path) as img:
self.sizes[str(self.out_path.relative_to('out/').as_posix())] = img.size