main #12
@ -8,7 +8,7 @@ bleach-allowlist==1.0.3
|
||||
blinker==1.7.0
|
||||
cffi
|
||||
click==8.1.7
|
||||
distribusi @ git+https://git.vvvvvvaria.org/crunk/distribusi@4cb03d1131a43669912433b0a5c18596712add20
|
||||
distribusi @ git+https://git.vvvvvvaria.org/crunk/distribusi@5934122c6ec1452d975b7cfe6582f9417fd5fdd0
|
||||
dnspython==2.1.0
|
||||
email-validator==1.1.3
|
||||
Flask==3.0.3
|
||||
|
@ -15,7 +15,8 @@ from sqlalchemy.exc import (
|
||||
InterfaceError,
|
||||
InvalidRequestError,
|
||||
)
|
||||
from exif import Image
|
||||
import piexif
|
||||
from PIL import Image
|
||||
from app import db
|
||||
from models.distribusi_model import Distribusis
|
||||
from models.distribusi_file_model import DistribusiFiles
|
||||
@ -76,7 +77,7 @@ def describe_file(file_id):
|
||||
distribusi_file.id, distribusi_file.path, distribusi_file.type
|
||||
)
|
||||
save_described_file_to_db(describe_form, distribusi_file)
|
||||
add_exif_to_image(describe_form, distribusi_file)
|
||||
add_alttext_to_file(describe_form, distribusi_file)
|
||||
distribusi = Distribusis.query.filter_by(
|
||||
id=distribusi_file.distribusi
|
||||
).first()
|
||||
@ -138,19 +139,10 @@ def save_described_file_to_db(describe_form, distribusi_file):
|
||||
flash("Error connecting to the database", "danger")
|
||||
|
||||
|
||||
def add_exif_to_image(describe_form, distribusi_file):
|
||||
def add_alttext_to_file(describe_form, distribusi_file):
|
||||
if not describe_form.alttext.data:
|
||||
return
|
||||
if distribusi_file.type != "image":
|
||||
return
|
||||
updating_image = bytearray()
|
||||
with open(distribusi_file.path, "rb") as image_file:
|
||||
image_bytes = image_file.read()
|
||||
updating_image = Image(image_bytes)
|
||||
updating_image.communication = describe_form.alttext.data
|
||||
with open(distribusi_file.path, "wb") as new_image_file:
|
||||
new_image_file.write(updating_image.get_file())
|
||||
print(
|
||||
f"{updating_image.communication} is set from form data: {describe_form.alttext.data}"
|
||||
)
|
||||
return
|
||||
filename_no_ext = os.path.splitext(distribusi_file.path)[0]
|
||||
with open(f'{filename_no_ext}_alttext.txt', 'w') as alttext_file:
|
||||
alttext_file.write(describe_form.alttext.data)
|
||||
return
|
||||
|
@ -98,7 +98,7 @@ def get_css_file(distribusi):
|
||||
def run_distribusi(userfolder, cssfile):
|
||||
print(f"Run distribusi on this folder: {userfolder} with css:{cssfile}")
|
||||
parser = build_argparser()
|
||||
args = parser.parse_args(["-t", "--menu-with-index", "-s", cssfile])
|
||||
args = parser.parse_args(["-t", "-a", "--menu-with-index", "-s", cssfile])
|
||||
distribusify(args, userfolder)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user