Package: cropyble
CropybleAuthor: Skyler BurgerVersion: 1.2.1OverviewCropyble is a class that allows a user to easily perform crops on an image containing recognizable text. This class utilizes optical character recognition (OCR) with the assitance of Tesseract OCR and Pytesseract. Images containing clear, printed, non-decorative text work best with the OCR capabilities.This is :sparkles: my first package on PyPI :sparkles: and I welcome feedback. Feel free to submit issues if you spot an area that could use improvement.ArchitecturePackagespillow: a Python package for manipulating imagespytesseract: Python bindings for Tesseracttesseract: a command-line program and OCR engineGetting StartedLinux & Mac OSThis class requires an additional piece of software that is not available through PyPI. Installtesseracton your machine withsudo apt-get install tesseract-ocrInstall Cropyble with eitherpip3 install cropybleor preferably with a environment manager such aspipenvPlace the following import statement at the top of your file:from cropyble import CropybleCreate Cropyble instances and get to cropping!Example:# example.pyfromcropybleimportCropyblemy_img=Cropyble('demo.jpg')my_img.crop('world','output.jpg')In the above example, imagine thatdemo.jpgis an image that contains the words 'hello world' and is located in the same directory asexample.py. An instance of Cropyble is created with a path to the input image. Cropyble then performs OCR on the image and stores information regarding the characters and words recognized, as well as their bounding boxes, within the instance of the class. By calling the.crop()method of the instance with a word contained in the image and a path to an output file, a cropped image of the word is created. The output file is created if it does not exist, or is overwritten if it already exists.APICropyble(input_path): Takes in a string representing the input image location. Cropyble runs OCR on the image usingpytesseractand stores the bounding boxes for recognized words and characters for future crops..crop(word,output_path): Takes in a string representing the word or character you'd like cropped from the image and a second string representing the output image path. Generates a cropped copy of the query text from the original image and saves it at the specified location..get_box(word): Takes in a string representing a word that was recognized in the image. Returns a tuple representing the bounding box of the word in the format (x1, y1, x2, y2). The origin (0, 0) for images is located in the top-left corner of the image..get_words(): Returns a list of words that were recognized within the input image.Change Log07/22/2019 - 0.1.0Corrected bounding box math. Images are being properly cropped.07/27/2019 - 0.2.0Refactored cropping functions into a class to minimize work needed to perform multiple crops on a single image.07/30/2019 - 0.3.0Cropyble can now accept a path for the input image and crop() accepts a path for the output image.08/02/2019 - 1.1.0Cropyble can now crop words and characters recognized within an image using the same crop() method.10/08/19 - 1.1.4Refactored for packagingUploaded to PyPI, bumpy ride01/06/20 - 1.2.0Added__repr__and__str__magic methods to Cropyble class.Added.get_box()and.get_words()methods to Cropyble class01/07/20 - 1.2.1Re-released to PyPI