Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

TutsPlus.com:
Render Text and Shapes on Images in PHP
Sep 25, 2018 @ 17:36:25

TutsPlus.com has continued their series of posts covering the use of image manipulation functionality in PHP using the GD library. In this latest tutorial they cover drawing shapes in images and rendering fonts.

Besides using GD for manipulating regular images, we can also create our own from scratch. Different functions in the library can be used to draw basic shapes like ellipses, circles, rectangles, polygons, and simple lines. With some maths, these shapes can create nice patterns. There are also functions available to draw text on the rendered image, which opens up a lot of possibilities.

This tutorial will teach you how to draw basic shapes in PHP and how to render text using your favorite font.

The tutorial starts by explaining what functions to use to draw lines, circles, arcs, rectangles, and polygons. Example code is provided showing all of these in action together to create a basic line drawing of a house and sun. They then enhance this with changes of line thickness, color fills and the use of a "brush" created from another image to make a new house picture. The tutorial finishes with a look at how to integrate fonts into the image and insert whatever text you might want (using a true-type font).

tagged: tutorial series image manipulation part3 text shapes

Link: https://code.tutsplus.com/tutorials/rendering-text-and-basic-shapes-using-gd--cms-31767

php[architect]:
Pro Parsing Techniques With PHP, Part Three Using Regular Expressions
Aug 29, 2018 @ 15:55:15

On the php[architect] site they've posted the latest part of their series of magazine excerpts sharing methods for parsing text with PHP. In this third (and last) part the author focuses on the use of regular expressions. This article was originally printed in the magazine's August 2018 edition.

This is the final installment of a set of three articles offering strategies for parsing text with PHP. The first article described the basics of parsing, followed by an article on developing fault tolerant parsing strategies. This article is dedicated to regular expressions.

Regular expressions, or sometimes simply called regex, represent a powerful set of tools which allow developers to split strings, perform character substitutions, and extract text based on matched patterns. The patterns, used in regular expressions, are an actual language that describe combinations of type castings and values that match the text you want to split, substitute, or extract. Regular expressions are an enormously powerful tool for the developer who understands them.

The tutorial starts by walking through some of the basics of what regular expressions are and the functions provided by PHP (using preg_*) to work with them (including basic code examples). It then briefly talks about pattern matching with regular expressions and gives a more specific example showing phone number extraction.

tagged: phparchitect august18 parsing text series part3 regularexpression tutorial

Link: https://www.phparch.com/2018/08/pro-parsing-techniques-with-php-part-three-using-regular-expressions/

SitePoint PHP Blog:
Picking the Brains of Your Customers with Microsoft’s Text Analytics
Oct 14, 2016 @ 17:19:21

In the latest tutorial posted to the SitePoint PHP blog author Wern Ancheta shows you how to integrate your application with the Microsoft Text Analytics API, a service offered by the company putting machine learning to work on things like keyword extraction, topic detection and language detection.

With the explosion of machine learning services in recent years, it has become easier than ever for developers to create “smart apps”. In this article, I’ll introduce you to Microsoft’s offering for providing machine-learning capabilities to apps. Specifically, you’ll learn about the Text Analytics API and build an app to enhance the understanding of online sellers when it comes to their customers.

The tutorial then introduces the Microsoft Cognitive Services API and, more specifically, the Text Analytics API that they'll be hooking the application in to. They walk you through getting an API key for the service, creating an "account" for the application you're working with and deploying it for immediate use. They introduce the functionality of the API with a few "play" examples of each API offered before getting into the creation of their sample application - a tool that reviews the contents of customer feedback, looking for key phrases and returns highlighted versions with what it sees as important.

tagged: customer tutorial text analytics microsoft machinelearning highlight feedback application slim3

Link: https://www.sitepoint.com/picking-the-brains-of-your-customers-with-microsofts-text-analytics/

SitePoint PHP Blog:
OCR in PHP: Read Text from Images with Tesseract
Oct 23, 2015 @ 17:14:27

The SitePoint PHP blog has a tutorial posted from author Lukas White showing you how to implement OCR in your PHP application and read text directly from images with the help of Tesseract.

Optical Character Recognition (OCR) is the process of converting printed text into a digital representation. It has all sorts of practical applications — from digitizing printed books, creating electronic records of receipts, to number-plate recognition and even circumventing image-based CAPTCHAs. [...] Tesseract is an open source program for performing OCR. You can run it on *Nix systems, Mac OSX and Windows, but using a library we can utilize it in PHP applications. This tutorial is designed to show you how.

They walk you through the installation of the Tesseract software locally (well, inside of a VM) and testing the install with the output from a sample image. With that up and working they show how to use this library to work with the Tesseract functionality, passing it in via a simple Silex application endpoint as a POSTed image file. Full code for the sample application is included as well as the results from another sample image. They also include some additional functionality you could use to detect phone numbers in the image content.

tagged: read text images tesseract tutorial library phonenumber

Link: http://www.sitepoint.com/ocr-in-php-read-text-from-images-with-tesseract/

PHPBuilder.com:
Using PHP Configuration Patterns Properly
Apr 16, 2014 @ 16:52:11

On PHPBuilder.com today they have a new post showing different configuration patterns for getting localized settings into your applications. They show the use of INI files, PHP scripts, text files, XML data and a database call.

PHP is a cross platform language. It is a server based application so we must think about the configuration settings of the PHP software. There are various ways of creating configurable PHP applications. The configuration flexibility comes as a built in feature in PHP. But we must understand the requirement clearly before making an application configurable. This article explores different PHP configuration patterns and their implementation.

For each of the options mentioned, there's a brief description of what the method is, some of the common uses and a code example showing a basic implementation. The database pattern is the only one without a code example as the database interface varies widely from application to application.

tagged: configuration pattern ini script text xml database

Link: http://www.phpbuilder.com/articles/application-architecture/using-php-configuration-patterns-properly.html

SitePoint PHP Blog:
Translation and Text-to-Speech with Microsoft Translator
Dec 05, 2013 @ 15:19:29

On the SitePoint PHP blog today there's a new tutorial showing you how to combine the Microsoft Azure platform services with their Translator API to create a text-to-speech translation service with some simple curl calls.

Text to speech is a popular technique used by many websites to provide their content in an interactive way. The generation of artificial human voice is known as Speech Synthesis. Even though it's highly popular, there are very few speech synthesis services, especially when looking for those free of charge. Microsoft Translator is one of the services we can use to get a speech service with limited features. In this tutorial, we are going to look at how we can use Microsoft Translator API to translate content and then make audio files using said content.

He walks you through setting up an Azure application (you'll need an account for the marketplace already) and how to subscribe to the translation service. It's a paid service but there's a "try before you buy" level that allows 2,000,000 characters of translation before it's cut off - perfect for testing. He includes the PHP to make the requests to the Translation API via curl. Included is code to initialize the configuration for the request, get the correct tokens and a reusable method for making the actual translation request. Finally, an example of doing the actual text-to-speech conversion is shown, resulting in an mp3 file.

He also includes an example of a simple frontend UI. You can see a working demo of the script here.

tagged: microsoft translator api texttospeech text speech tutorial azure service

Link: http://www.sitepoint.com/translation-text-speech-microsoft-translator/

PHPMaster.com:
Adding Text Watermarks with Imagick
Dec 31, 2012 @ 15:15:48

On PHPMaster.com there's a recent tutorial from Martin Psinas about how you can add text to an image with the help of Imagick, the image editing software that's available to PHP via an extension.

In a previous article, Timothy Boronczyk wrote about how to create watermarks with Imagick using an overlay image. In this article, I’ll show you how to achieve a similar effect using plain text.

He takes a sample image (a headshot) and offers two versions of the same functionality - both the shell command (using "convert") and the PHP code that sets up the font to use, adds placement and pushes the result back out as a PNG. He also includes two other types of overlay - a font mask for a more see-through look and a tiled version, overlaying the text all over the image.

tagged: watermark imagick tutorial text overlay mask tile

Link:

LearnComputer.com:
Sending Text Messages with PHP
Sep 25, 2012 @ 14:15:38

In this new tutorial on LearnComputer.com, they show you how to, using a simple call to PHP's mail function, you can send a text message to anyone.

Text messaging seems more convenient than making phone calls and creating your own PHP script to send these messages is a very easy thing to set up. Get on board with these other companies that have found how convenient text messages are for their customer and start integrating text messaging into your PHP applications. In this article, I will show you two ways to accomplish this and you will be surprised at how simple this is to do.

Once you've found the right email address for the provider, sending the message is pretty simple using mail. As an alternative, they recommend a service like TextMagic to send the messages. It's a bit more reliable and uses SMS instead of email to get your message out.

tagged: text message email textmagic sms tutorial

Link:

PHPMaster.com:
WordPress Plugin Development
Feb 20, 2012 @ 16:50:39

On PHPMaster.com today there's a new tutorial showing how you can create a custom WordPress plugin for the popular PHP-based blogging/CMS tool.

If you’ve ever used WordPress to build a site quickly, chances are you’ve used one of the many plugins that are offered to extend the functionality of this popular blogging software. Plugins are one of the many things that make WordPress so attractive. [...] There are times, however, when you can’t quite find what you need from existing plugins. This article will show you how to create your own WordPress plugins by walking you through an example to display some text using a widget in a the sidebar.

He walks you through all of the steps you'll need to create the plugin - making the main plugin file (definition) and using some of the methods available to create the functionality: update, form, widget and the constructor to set it all up.

tagged: wordpress plugin development introduction simple text form

Link:

Martin Psinas' Blog:
Watermarking with text and ImageMagick
Oct 04, 2011 @ 16:44:35

Martin Psinas has submitted a new tutorial he's written up (complete with sample code) showing how to watermark an image with ImageMagick.

In my most recent venture with PHPMaster I was asked to write an article about watermarking images with PHP using ImageMagick. Virtually no documentation exists on the PHP API, although there are plenty of command-line examples from the official ImageMagick website. I spent a solid day and a half attempting to convert command-line code into PHP before (due to miscommunication) the topic was covered by someone else and my work was no longer needed. Although disappointed, it gave me something to blog about! Yay.

His script is pretty straight forward - it loads a sample image, sets up some watermark text and applies it with a "gravity" setting of "southwest" and adds it to the image (annotateImage). The output is pushed back out as a JPEG image. Also included is a slightly more complex example showing how to give the watermark an embossed look and a "text all over the image" look to prevent use of any part of the image, not just one section.

tagged: watermark text image tutorial imagemagick emboss

Link:


Trending Topics: