dramp77 commited on
Commit
8fe1a1d
·
verified ·
1 Parent(s): 1635a40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -476,11 +476,18 @@ def position_logic_none(image, canvas_size):
476
  # Resize gambar dengan ukuran baru
477
  image = image.resize((new_width, new_height), Image.LANCZOS)
478
 
479
- # Posisi tengah canvas
480
  x = (target_width - new_width) // 2
481
- y = (target_height - new_height) // 2
482
 
483
- print(f"Image centered: size={new_width}x{new_height}, position=({x},{y})")
 
 
 
 
 
 
 
 
484
  log = [{"action": "resize_and_center", "new_size": f"{new_width}x{new_height}", "position": f"{x},{y}"}]
485
  return log, image, x, y
486
 
 
476
  # Resize gambar dengan ukuran baru
477
  image = image.resize((new_width, new_height), Image.LANCZOS)
478
 
479
+ # Posisi tengah canvas dengan offset dari atas
480
  x = (target_width - new_width) // 2
 
481
 
482
+ # Tambahkan 30px dari posisi tengah ke bawah (offset dari atas)
483
+ top_offset = 30
484
+ y = (target_height - new_height) // 2 + top_offset
485
+
486
+ # Pastikan gambar tidak keluar dari canvas di bawah
487
+ if y + new_height > target_height:
488
+ y = target_height - new_height
489
+
490
+ print(f"Image centered with top offset: size={new_width}x{new_height}, position=({x},{y})")
491
  log = [{"action": "resize_and_center", "new_size": f"{new_width}x{new_height}", "position": f"{x},{y}"}]
492
  return log, image, x, y
493