generated from hjess/PythonTemplateProject
[main] Images images images
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 51s
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 51s
This commit is contained in:
@@ -5,6 +5,8 @@ from typing import List, Dict
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
from app.services.image_service import ImageService, FileHandler
|
||||
|
||||
|
||||
class MetadataProcessor:
|
||||
"""
|
||||
@@ -22,6 +24,7 @@ class MetadataProcessor:
|
||||
"""
|
||||
self.input_dir = input_dir
|
||||
self.output_file = output_file
|
||||
self.app = app
|
||||
self.data = {"categories": [], "favorites": []}
|
||||
|
||||
def _extract_metadata(self, file_path: str) -> Dict:
|
||||
@@ -66,11 +69,25 @@ class MetadataProcessor:
|
||||
|
||||
# Add to 'favorites' if 'favorite' is true
|
||||
if metadata.get("favorite") and metadata["favorite"].lower() == "true":
|
||||
image_type = "thumbnails"
|
||||
category = os.path.relpath( root, self.input_dir ).replace( os.sep, "/" )
|
||||
filehandler = FileHandler(category=category, image_type=image_type, filename=metadata.get("image"))
|
||||
imageservice = ImageService(self.app)
|
||||
default_size = imageservice.get_image_size( image_type )
|
||||
width = default_size.get( "width" )
|
||||
height = default_size.get( "height" )
|
||||
|
||||
image_tag = imageservice.image_tag(category, image_type, metadata.get("image","Unkown"))
|
||||
print(filehandler.dest_filename_webp)
|
||||
print(image_tag)
|
||||
self.data["favorites"].append({
|
||||
"name": metadata.get("name", "Unknown"),
|
||||
"image": metadata.get("image", "images/default.jpg"),
|
||||
"image": filehandler.dest_filename_webp,
|
||||
"height": height,
|
||||
"width": width,
|
||||
"description": metadata.get("summary", "No description provided"),
|
||||
"path": os.path.relpath(root, self.input_dir).replace(os.sep, "/"),
|
||||
"path": category,
|
||||
|
||||
})
|
||||
|
||||
def generate_json(self):
|
||||
|
||||
Reference in New Issue
Block a user