graphics – How to import and cut n images in 6 parts hopefully proportional to the written and export them to a directory?


I tried to get it well formatted but I won it

I hope the question is understood
I’m using the google form which allows you to do multiple choice tests, if they were language no problem, the problem they are math exercises and the only way they look decent is by inserting pictures both in the problem header with in the alternatives, but cutting each picture of each problem means 6 cuts and if they are 30 questions is a long time.
The idea is to have “x” amount of images in a directory and that mathematician import them one by one P01.png,P02.png…. and identify the black color of the writing and cut the image in 6 parts if you can of the same size of the writing and name them of the form p01. png, p01_a.png,p01_b.png,p01_c.png ,p01_d.png,p01_e.png,p02.png, p02_a.png,p02_b.png,p02_c.png ,p02_d.png,p02_e.png……. and save them in a subdirectory “y” inside “x
Someone could help me please

Image from P01.png
Image from P01.png

 Image from p01.png
Image from p01.png

Image from p01_a.png
Image from p01_a.png

  Image from p01_b.png
Image from p01_b.png

Image from p01_c.png
Image from p01_c.png]

Image from p01_d.png
Image from p01_d.png

Image from p01_d.png
Image from p01_e.png