Я пытаюсь создать программу, которая загружает изображение, а затем разбивает его на разные части и сохраняет эти разные части в папке. Однако вместо сохранения обрезанного изображения сохраняется все изображение
import sys, pygame
from pygame import *
pygame.init()
while True:
image=pygame.image.load(raw_input("Enter the file: "))
rows=int(input("Enter the number of rows: "))
columns=int(input("Enter the number of columns: "))
output=raw_input("Enter the output folder: ")
width=image.get_width()/columns
height=image.get_height()/rows
print ("In progress...")
for i in range(0, rows):
for j in range(0, columns):
cropped_image=pygame.transform.chop(image, (j*columns, i*rows, width, height))
cropped_output=output+"/" + str(i)+"_"+str(j)+".png"
pygame.image.save(cropped_image, cropped_output)
print ("completed")
вместо сохранения cropped_image (только часть изображения) сохраняет все изображение. Есть идеи, почему это не работает?
Спасибо