by Vincy. Last modified on July 8th, 2022. Show
Most of the image based operations can be performed by using PHP built-in functions. The image-based PHP functions are in GD library and we can use them for converting text into an image. Before that, we must ensure that the GD library is enabled in the php.ini configuration. You can also run the PHP function phpinfo() to check if the GD is enabled. View Demo I submit a text input via a HTML form to the PHP code. In PHP, I invoke GD library functions to convert this text input into an image. I create image layers for putting the text and a background. Then, I merged the layers and copy the required portion to show the final output image to the browser. If no text is entered, then it will be resolved with the JavaScript validation. This screenshot shows the final output after converting the text input to an image. This example may be useful for creating custom captcha using PHP. Get and Validate Text Input via HTML FormThis code shows the HTML form to get the text input from the user. On submitting this form, the text input will be validated using JavaScript and sent to the PHP. After processing image conversion, the output image will be displayed below this form
Converting Text to an Image using PHP GD functionsIn PHP, with the use of GD library function, we can convert text input to an image. I created a transparent image layer to place the text input onto it. Then I created a background image layer and merge it together with the text input layer using imagecopymerge(). After merging, I slice the required part of the merged layer by using imagecopy() and output the final image to the browser.
View DemoDownload ↑ Back to Top We are now APPSeCONNECT. Welcome to the Future of Automation. Visit Now Skip to content
Get to know to use OCR within PHP to convert image to textFor various business reasons, you may want to convert an image file to text. Programs can be written to to achieve this using optical character recognition (OCR). Considering that many web applications are being written in PHP, lets take this opportunity to see how OCR can be leveraged within PHP to convert an image to text. Also refer to the article below to understand the use cases of image to text conversion. Looking for a PHP development team? Reach out to us. If you want a little more background on how what optical character recognition is you can find this link useful. Tesseract is one of the popular OCR engine, which was developed by Hewlett Packard and now works with most of the platforms and various programming languages. Since it works very well with PHP, we will be using Tesseract for this example. PHP OCR image to text conversion using TesseractIn this section of the article, we will explore the image to text conversion in a step by step manner. For this the first step is to install Tesseract. You can find the steps to install the same below. Get to know the top things you must consider before outsourcing PHP developments. #1. Install TesseractThe fist step in this exercise would be to install Tesseract. Following are the instructions on how the library can be installed in Ubuntu and macOS operating systems. For Ubuntu 18.04 users$ sudo apt install tesseract-ocr For macOS Users
#2. Add PHP library to interact with the OCR to the projectThe next step is to enable/add the Tesseract library so that it is available for PHP scripts. Following is the command to do the same.
#3. Sample PHP code to invoke image to text conversionGiven below is a sample PHP code which takes the path of an image file from the file directory. It uploads the file before calling the Tesseract library and converts the same into text and outputs the same on the display. You can find the code snippet on GitHub. The following code is sample code to access the OCR engine to upload a image file from a directory and process it for text conversion. Use case of image to text conversionFollowing are some of the use cases for image to text conversion we have come across for parsing the image into text file. CRM image uploadMany a times, sales representatives are in a hurry to gather information. Many a times, the information may be in a picture format. They would want it to be in a text format so that it can be used to update the respective customer record and be available for reporting. Check out our CRM development service offerings. Toll TagMany paid highways use OCR for reading the license plate of vehicles. Depending on the entry and exit points on the highway, the bill is generated and sent to the vehicle owner. Statement and journal conversionFor statements and journal entries which are available in picture and need to be entered into financial system, this can be done via OCR. Coupon and Promotion via mobile APP picture data uploadMobile APP users may want to capture pictures and get it converted to text before getting it uploaded to back end system. Information such as voucher and coupons can be scanned. Check out the popular OCR APP on Apple Store. Fleet TrackingLarge fleet owners want to track entry and exit of cars into the parking. For this an OCR application can be used to read the movement of the cars. Mobile Banking / Check uploadIf you are looking at building a banking application which can upload checks, you can use this concept to validate check information like amount, routing number and account number. Kindly note that this may require an additional layer of MICR instead of mere OCR. From the above use cases, we can understand that OCR can tremendously improve user experience. We really hope that you learnt all about using image to text conversion using OCR in PHP. We wish you all the best for your next development project. Evaluating SugarCRM for your business – We can help Reach out to us so that we can assess and plan a road-map for your PHP development needs. Let’s build a system, which you will use for years to come. Take your business to the next levelSchedule a free 15 minutes no obligation call with one of our experts. Change the way you interact with customers. Consult NowBy Divya Sahu|2021-04-06T10:33:25+00:00April 13th, 2020|CRM, SugarCRM, SuiteCRM|Comments Off on Get to know to use OCR within PHP to convert image to text
Divya is a CRM consultant at Veon Consulting. She helps companies derive the maximum benefit from applications such as SugarCRM and SuiteCRM. She also works on custom PHP developments. Her interests are interior decoration and travelling. Related PostsGDPR AcceptanceThis website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read MorePrivacy OverviewThis website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience. Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information. Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
Veon is now APPSeCONNECT!Welcome to the Future of Automation. Explore the modern integration platform to automate your business! |