mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Figure out
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
total_commands=28
|
total_commands=29
|
||||||
current_command=0
|
current_command=0
|
||||||
|
|
||||||
function print_progress {
|
function print_progress {
|
||||||
@@ -92,6 +92,9 @@ print_progress "cp ./conjurer/latex_commands.py ./Conjurer/"
|
|||||||
cp ./conjurer/latex_functions.py ./Conjurer/
|
cp ./conjurer/latex_functions.py ./Conjurer/
|
||||||
print_progress "cp ./conjurer/latex_functions.py ./Conjurer/"
|
print_progress "cp ./conjurer/latex_functions.py ./Conjurer/"
|
||||||
|
|
||||||
|
cp ./conjurer/librarian_functions.py ./Conjurer
|
||||||
|
print_progress "cp ./conjurer/librarian_functions.py ./Conjurer/"
|
||||||
|
|
||||||
cp ./conjurer/thin_client.py ./Conjurer/bot.py
|
cp ./conjurer/thin_client.py ./Conjurer/bot.py
|
||||||
print_progress "cp ./conjurer/thin_client.py ./Conjurer/bot.py"
|
print_progress "cp ./conjurer/thin_client.py ./Conjurer/bot.py"
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from queue import Empty
|
|||||||
|
|
||||||
import discord
|
import discord
|
||||||
import pdf2image
|
import pdf2image
|
||||||
#import fitz
|
import fitz
|
||||||
import PyPDF2
|
import PyPDF2
|
||||||
import requests
|
import requests
|
||||||
from discord.ext import commands, tasks
|
from discord.ext import commands, tasks
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# pdf_render.py
|
||||||
|
import io
|
||||||
|
|
||||||
|
try:
|
||||||
|
import fitz # PyMuPDF
|
||||||
|
_HAS_PYMUPDF = True
|
||||||
|
except Exception:
|
||||||
|
_HAS_PYMUPDF = False
|
||||||
|
from pdf2image import convert_from_path
|
||||||
|
|
||||||
|
def pdf_page_to_image_bytes(path: str, page_index: int = 0, zoom: float = 2.0, fmt: str = "PNG") -> bytes:
|
||||||
|
"""
|
||||||
|
Zwraca bytes obrazka z jednej strony PDF:
|
||||||
|
- PyMuPDF (szybki) jeśli dostępny,
|
||||||
|
- inaczej pdf2image + poppler (wymaga 'pdftoppm').
|
||||||
|
page_index: 0-based
|
||||||
|
"""
|
||||||
|
if _HAS_PYMUPDF:
|
||||||
|
doc = fitz.open(path)
|
||||||
|
page = doc.load_page(page_index)
|
||||||
|
mat = fitz.Matrix(zoom, zoom)
|
||||||
|
pix = page.get_pixmap(matrix=mat, alpha=False)
|
||||||
|
return pix.tobytes(fmt.lower())
|
||||||
|
# fallback
|
||||||
|
images = convert_from_path(path, first_page=page_index+1, last_page=page_index+1, fmt=fmt)
|
||||||
|
bio = io.BytesIO()
|
||||||
|
images[0].save(bio, fmt)
|
||||||
|
return bio.getvalue()
|
||||||
@@ -13,7 +13,7 @@ spotipy
|
|||||||
tiktoken
|
tiktoken
|
||||||
PyNaCl
|
PyNaCl
|
||||||
flask[async]
|
flask[async]
|
||||||
fitz
|
PyMuPDF
|
||||||
waitress
|
waitress
|
||||||
clickupython
|
clickupython
|
||||||
assemblyai[extras]
|
assemblyai[extras]
|
||||||
|
|||||||
Reference in New Issue
Block a user