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

NetTuts.com:
Resize and Manipulate Images in PHP (With Examples)
Sep 14, 2018 @ 15:38:31

The NetTuts.com site has continued their series covering the use of the GD functionality in PHP to manipulate images with a new tutorial posted today. In this second part of the series they focus in on resizing and manipulating images.

In my previous tutorial, we discussed basic image manipulation using the PHP GD library. In that tutorial, I gave a brief introduction to the library and showed you how to load images from a file or create them from scratch in PHP. After that, we learned how to crop, rotate, scale and flip an image using GD. I covered the imagefilter() function to apply different filters to image resources loaded in the script. I also mentioned some useful functions in GD like imagesx() and imagesy() to get the width and height of the loaded image.

By the end of my last GD tutorial, you learned how to use the library to automate basic tasks like resizing all images in a directory or applying filters like grayscale on them before saving the final result. [...] In this tutorial, we will learn about many more useful functions in GD and how they can be used to automate more of our image manipulation tasks.

They start by looking at the imageconvolution function and the use of a "convolution matrix" and how it can be useful to blur, sharpen, emboss, or detect edges on an image. It then covers the functions used to copy images and alter the end result by changing contrast or converting to grayscale. Finally, the author shows how to use the GD functionality to dynamically add a watermark to the image and output the result to a new file.

tagged: gd graphics tutorial resize manipulate image

Link: https://code.tutsplus.com/tutorials/php-gd-image-manipulation-beyond-the-basics--cms-31766

TutsPlus.com:
Manipulating Images in PHP Using GD
Sep 04, 2018 @ 17:12:04

On the TutsPlus.com site they've posted a new tutorial for those needing to manipulate images in their PHP applications. In this new tutorial they walk you through the basics of using the GD image processing functionality that's included in every PHP release.

The internet would be pretty dull without images. However, maintaining and manipulating hundreds or thousands of images for your web site can be a headache. As your site design changes, you might need to modify all your images—for example, you might need to convert all your images to grayscale or resize them to 50% of their original size. You might also want to compress or crop different images. Doing this manually is time-consuming and error-prone, but with a little programming knowledge it can be automated.

In this tutorial, you will learn about the GD (Graphic Draw) library in PHP. You'll see how this library can be used to manipulate images by resizing, cropping, rotating or filtering them.

The post starts with a bit of background on GD and how to set it up on Windows versus Unix-based environments. They then get into some of the functionality that comes with GD including:

  • getting data about the image
  • flipping and rotating
  • applying filters (ex: brightness, contrast)

The post also includes two "real world" examples of GD in use: resizing an entire directory of images and applying grayscale/contrast filters to images.

tagged: manipulating image gd tutorial introduction

Link: https://code.tutsplus.com/tutorials/manipulating-images-in-php-using-gd--cms-31701

SitePoint PHP Blog:
Finding Differences in Images with PHP
May 26, 2016 @ 15:56:33

The SitePoint PHP blog has posted a new tutorial from author Christopher Pitt on an interesting topic that could come in very handy in the right situations: finding differences in images with PHP.

I recently stumbled across a fascinating question: how could I tell whether an image had changed significantly? As PHP developers, the most troublesome image problem we have to deal with is how to resize an upload with an acceptable loss of quality. In the end I discovered what many before me have – that this problem becomes relatively simple given the application of some fundamental mathematical principles.

He starts off by talking about images as "bitmaps", basically a collection of pixels composed in a grid. He also mentions images as sets of vectors, but in PHP the bitmap approach is simpler and more understandable. He includes some code showing the breakdown of an image into its RBG colors values and what the data represents. He then moves into measuring the distance "in three dimensions" with a bit of geometry and applies them to a simple State class. This class breaks down the image given into RBG details then, eventually, compares the other image based on the euclidean distance between the points on the original and the ones from the new image. He filters some of these results through a standard deviation view to weed out problems with almost identical images.

tagged: image difference evaluation tutorial gd similar euclideandistance standarddeviation

Link: https://www.sitepoint.com/finding-differences-in-images-with-php/

SitePoint PHP Blog:
Simple Captchas with PHP and GD
Mar 07, 2014 @ 18:05:38

On the SitePoint PHP blog there's a new post by Mahul Jain looking at a simple way to create CAPTCHA images in PHP using the built-in GD libraries.

By now, we’ve all encountered captcha images in online forms. Captchas are a necessary evil, and this article will teach you how they’re made. Please note that while there are better, automatic third party solutions for captchas out there such as ReCaptcha, this tutorial aims merely to explain and demonstrate how such technology actually works. We won’t be explaining what captchas actually are, as it’s assumed to be common knowledge and already covered in greater detail elsewhere.

He walks you through the whole process of making the sample CAPTCHA (like this one):

  • Display an empty image on the browser
  • Create a shape
  • Generate random lines
  • Generate random dots
  • Generate random text

There's screenshots all along the way too for reference as to what your result should look like. You can download the full code over on GitHub.

tagged: captcha gd tutorial introduction

Link: http://www.sitepoint.com/simple-captchas-php-gd/

SitePoint PHP Blog:
Imagick vs GD
Nov 29, 2013 @ 00:16:34

In a new post to the SitePoint PHP blog Jacek Barecki has written up a comparison of two of the most widely used PHP image manipulation libraries - Imagick and GD.

If you want to create a thumbnail, apply a filter to an image or transform it in any other way, you will have to employ an image processing library in your PHP application. It means that you will probably choose GD or ImageMagick. But which one supports a wider range of image formats? Maybe one of them is slower than the other? What other criteria should be taken under consideration when choosing the right library?

He compares them on a few different aspects:

  • Availability
  • Supported file types
  • Functionality
  • Performance
  • Coding style
  • Popularity

He also provides three alternatives to using GD or Imagick, most involving outside services or software.

tagged: imagick gd image manipulation library tutorial

Link: http://www.sitepoint.com/imagick-vs-gd/

Anonwhat:
ASCII Art Generator
Aug 07, 2013 @ 14:52:18

In the "something completely different" category today, anonwhat has created an image-to-ASCII art tutorial that takes in an image and, using PHP's GD functionality and a bit of logic, transforms it.

In this tutorial, we are going to create a simple web-based ASCII Art Generator. The concepts found in this tutorial can be applied to other languages. [It is] a simple ASCII Art Generator takes in an image, grayscales it, pixelates it, then prints out a character for each block on the pixelated image based on how “dark” the block is.

The tutorial walks you through the steps needed to make the simple script. It analyzes the image looking at the "blackness" (a combination of the values from imagecolorat and imagecolorsforindex). ACSII characters are then substituted for different "blackness" ranges with the result looking something like this.

tagged: ascii art image tranform blackness gd tutorial

Link: http://fuzzicode.com/create/ascii-art-generator

PHPMaster.com:
Charting with pChart
Dec 05, 2011 @ 14:50:07

On PHPMaster.com today there's a new post highlighting the use of pChart to graph out the data from your PHP application. pChart provides an easy interface to draw graphs with GD, supporting alpha transparency, shadowing, spline/cubic curves and much more.

Created and maintained by Jean-Damien Pogolotti, a systems engineer based in Toulouse, France, pChart is a library that creates anti-aliased charts and graphs using PHP. It's object-oriented code has been recently redesigned and makes it easy to add beautiful, eye-catching data. The library is free for non-profit use and for inclusion in GPL distributed software; licensing plans for other uses start at just 50 Euro. In this article I'll take you through installing pChart and using it to generate a basic chart, line chart and plot graph.

He walks you through the download and installation of the tool as well as showing the code you'll need to include to get started with a first script. Their examples show how to create both single- and three-series charts with some sample data and some screenshots of output.

tagged: pchart tutorial library gd graph

Link:

Script-Tutorials.com:
Creating a Smooth Curve Graphs with PHP and GD
Oct 25, 2011 @ 16:27:51

On Script-Tutorials.com there's a new tutorial posted showing you how you can get better curves on your graphs with PHP and GD (the key is in the "CubicSplines" class, providing a few extra calculations to make "splines", a mathematical method for smoothing out values).

Today I have new article for PHP. I will tell you about drawing graphs with GD. Plus – we will smooth our graph with curve lines using cubic splines interpolation method. You can read more about method at Wikipedia.

All of the code is included in the post, ready for cop and pasting - the HTML, CSS plus the PHP to generate the graph, plot the points and apply the cubic splines values. You can check out a live demo of it in action or just download the code and get started on your own.

tagged: smooth curve graph gd tutorial cubic splines

Link:

.Net Magazine:
Create an SVG data visualization with PHP
Sep 13, 2011 @ 17:13:25

On the .net magazine site (yes, really) there's a recent post from Brian Suda about creating SVG images with PHP thanks to the GD functionality that's included in every release.

If you’re working online, then canvas springs to mind. It allows you to draw raster graphics quickly and easily. If you want, there are also plenty of image code libraries that can generate GIFs, JPEGs and PNGs on request. But what if your target isn't always online? What if you’re aiming for print? Then you could use a raster graphic, but it would need to be pretty large. A better solution is to create a vector-based image format from your code. This is where SVG (Scalable Vector Graphics) steps in.

He starts by explaining a bit about SVG and what it is for those that haven't worked with it before. He givesn an example of a poster from Wired showing circles with colors from their covers over the last 15 years. He shows how to do something similar with images of the .net magazine covers, pulling out the color frequency with the imagecolorat function. Toss in a bit of markup and some formatting of the color output and you'll get circles with concentric rings with the most prominent colors ending up the largest. You can see his result here.

tagged: svg tutorial gd image color frequency

Link:

Script-Tutorials.com:
Watermark processing on images using PHP and GD
Sep 09, 2011 @ 17:36:06

On the Script-Tutorials blog today there's a new tutorial posted showing you how to easily add watermarks to your images dynamically, either as a part of a cache generation or on upload.

I will show you how to use GD library. And, main task today is adding watermark to image and generate result as PNG image into browser. We will using PHP and GD library. This is nice library to work with images at server side. Also (as additional tasks) I will draw little frame over image and will draw some text. Between, you can use this method (of adding watermarks in realtime) to protect original photos.

Full code for the script is included in the post, showing the combining of two images into the one finished product. The code is also available for download if you'd like to get hacking right away.

tagged: watermark image gd combine tutorial

Link:


Trending Topics: