Files
gpt-edit/tests/test_b64.py
2025-08-25 00:39:39 +09:00

49 lines
1.3 KiB
Python

"""Test script for base64 image input"""
import base64
import asyncio
from pathlib import Path
from src.server.handlers import ToolHandlers
from src.connector import Config
async def test_b64_edit():
"""Test editing with base64 input"""
# Initialize config and handlers
config = Config()
handlers = ToolHandlers(config)
# Read test image and convert to base64
test_image_path = Path("inputs/test.png") # You need to put a test image here
if not test_image_path.exists():
print(f"Please place a test image at {test_image_path}")
return
with open(test_image_path, "rb") as f:
image_data = f.read()
image_b64 = base64.b64encode(image_data).decode('utf-8')
# Test edit_image with base64
print("Testing edit_image with base64 input...")
arguments = {
"input_image_b64": image_b64,
"prompt": "Make the image more colorful and vibrant",
"background": "transparent",
"save_to_file": True
}
result = await handlers.handle_edit_image(arguments)
# Print result
for content in result:
if hasattr(content, 'text'):
print(content.text)
print("\nTest completed!")
if __name__ == "__main__":
asyncio.run(test_b64_edit())