Image manipulations take a lot of memory especially with the several resize steps you have in the server action. See: