pyblock/pybitblock/imgterminal.py
GaltRanch 0224cfe230 Fix critical security vulnerabilities across the codebase
Replace insecure patterns that exposed the application to command injection,
arbitrary code execution, and data interception attacks.

- Replace os.popen/os.system with subprocess.run using argument lists
- Migrate pickle config serialization to JSON format
- Replace bare except: blocks with specific exception types
- Fix insecure HTTP URLs to HTTPS (opreturnbot.com, ascii.live)
- Replace shell curl commands with requests library calls
- Add migrate_config.py script for pickle-to-JSON config migration
- Convert existing SPV config files to JSON format

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 10:24:47 -03:00

40 lines
1.4 KiB
Python

import shutil
import os
import subprocess
from PIL import Image as PILImage
from term_image.image import from_file
def set_terminal_background(color="black"):
if color == "black":
subprocess.run(['printf', '\033[40m']) # Secuencia de escape ANSI para fondo negro
elif color == "reset":
subprocess.run(['printf', '\033[49m']) # Secuencia de escape ANSI para restaurar el fondo
def createimagebitaxe():
# Ruta al archivo de imagen
image_path = "bitaxe.jpg"
# Cargar la imagen usando PIL y redimensionarla
pil_image = PILImage.open(image_path)
# Obtener el tamaño de la terminal
terminal_size = shutil.get_terminal_size()
# Ajustar el tamaño de la imagen según el tamaño de la terminal
# Restar algunos caracteres para asegurarse de que encaje bien
max_width = (terminal_size.columns - 4) * 2 # Ajustar el factor según sea necesario
max_height = (terminal_size.lines - 4) * 4 # Ajustar el factor según sea necesario
# Redimensionar la imagen manteniendo la proporción
pil_image.thumbnail((max_width, max_height))
# Guardar la imagen redimensionada temporalmente
temp_image_path = "resized_image.png"
pil_image.save(temp_image_path)
# Cargar la imagen redimensionada usando term-image
image = from_file(temp_image_path)
# Envolver el comando draw en secuencias de escape para mantener el fondo negro
image.draw()