Search code examples
ocrimagemagick-convert

Spit PNG into multiple images on Ubuntu with imagemagick


This image contains 30 blocks of user data. I plan to extract these 30 blocks as PNG files and then run tesseract-ocr to extract text from them. Can someone tell me how I can use imagemagick to get those 30 PNG files?


Solution

  • The following works for me in ImageMagick. I first crop to the array of boxes. Then I crop a set of 3x10 equal sized boxes.

    convert image.png -crop 1125x1500+43+99 +repage -crop 3x10@ +repage result_%02d.png
    

    See http://www.imagemagick.org/Usage/crop/#crop_repage http://www.imagemagick.org/Usage/crop/#crop_equal