summaryrefslogtreecommitdiff
path: root/texture.py
diff options
context:
space:
mode:
authorTim Keller <tjk@tjkeller.xyz>2025-12-09 22:16:48 -0600
committerTim Keller <tjk@tjkeller.xyz>2025-12-09 22:16:57 -0600
commit3e7fdfb6c8a50c59ac933f701526ad1815dded92 (patch)
treed2c699ff93e23d0fe45845a4c2dc05d820ec317b /texture.py
parent39738b84e9164b0f2d01f22440548c4393160013 (diff)
downloadimmich-frame-3e7fdfb6c8a50c59ac933f701526ad1815dded92.tar.xz
immich-frame-3e7fdfb6c8a50c59ac933f701526ad1815dded92.zip
refactor codebase. Reorganize file structure. Replace webpack for vite. Setup setuptools for application. Move closer to distributable appv0.3.0
Diffstat (limited to 'texture.py')
-rw-r--r--texture.py67
1 files changed, 0 insertions, 67 deletions
diff --git a/texture.py b/texture.py
deleted file mode 100644
index 3a56b5f..0000000
--- a/texture.py
+++ /dev/null
@@ -1,67 +0,0 @@
-from OpenGL.GL import *
-from OpenGL.GLUT import *
-from OpenGL.GLU import *
-from PIL import Image, ExifTags
-
-
-class ImageTexture:
- def __init__(self, image_source, exif=None):
- self.id = None
- img = Image.open(image_source)
- self.exif = exif or self.get_exif(img)
- img = self.handle_orientation(img, self.exif)
- img = img.convert("RGBA") # Ensure the image is in RGBA mode
- self.width = img.width
- self.height = img.height
- self._img_data = img.tobytes("raw", "RGBA", 0, -1) # Convert image data to bytes
- self.initialized = True
-
- def gl_init(self):
- if self.id:
- return
- #glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
- self.id = glGenTextures(1)
- glBindTexture(GL_TEXTURE_2D, self.id)
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, self.width, self.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, self._img_data)
- #glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, img.width, img.height, 0, GL_RGB, GL_UNSIGNED_BYTE, img_data)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
- del self._img_data # No longer needed, clear mem
-
- #print(f"Loaded texture {self.id}")
-
- def free(self):
- if self.id is None:
- del self._img_data
- else:
- glBindTexture(GL_TEXTURE_2D, 0) # Unbind
- glDeleteTextures([self.id])
-
- @staticmethod
- def get_exif(img):
- return { ExifTags.TAGS[k]: v for k, v in img.getexif().items() if k in ExifTags.TAGS }
-
- @staticmethod
- def handle_orientation(img, exif):
- orientation = exif.get("Orientation", 1) if exif is not None else 1
-
- if orientation == 3: return img.rotate(180, expand=True)
- if orientation == 6: return img.rotate(270, expand=True)
- if orientation == 8: return img.rotate( 90, expand=True)
-
- return img
-
-
-class ImageTextureImmichAsset(ImageTexture):
- def __init__(self, asset, asset_index):
- self.initialized = False
- self.asset_index = asset_index
- self.asset_key = asset["id"]
- self.exif = asset.get("exif", None)
-
- # So that free can work
- self.id = None
- self._img_data = None
-
- def initialize(self, image_source):
- super().__init__(image_source, self.exif)