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

.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:

Zend Developer Zone:
Creating Scalable Vector Graphs with PHP
Mar 09, 2010 @ 16:27:54

A new tutorial has been posted to the Zend Developer Zone today looking at making scalable vector graphics with PHP and the hep of one of two charting packages - ezcGraph or SVGGraph (examples are provided for both).

Programmatically generating graphs and charts using SVG requires a deep understanding of the SVG specification and the various SVG primitives, as well as a fair amount of time for research, experimentation and debugging. Or, in other words, that's your entire weekend shot! Fortunately, help is at hand. There are a number of open-source PHP libraries that support SVG chart generation, and using them can significantly reduce the amount of work involved in adding this feature to a Web application.

He shows how to create simple images like bar, line and pie charts as well as adding in other things like a legend, custom titles and a sample where the user can define the sizes of a pie chart via some form input fields. Screenshots are included for all code examples to give you a better idea of the end result.

tagged: scalable vector graphic ezcgraph svggraph tutorial svg

Link:

PHPBuilder.com:
Using PHP for the Creation of SVG Images
Dec 04, 2008 @ 15:37:57

On the PHPBuilder.com site today there's a new tutorial talking about using PHP to dynamically create SVG images in a simple application.

As with many of the pages on my Web site, my SVG images are in fact generated by PHP scripts. I end up including many of the same images in other pages, but not always with the same size or colors, so making them customizable on a case-by-case basis is a useful thing. Attributes such as size, scale, colour, rotation, and position are obtained from arguments in the URL.

His example creates a SVG image using a class (UIControl) to create the content for the image. This content is dropped into the typical XML structure to display it. He also includes some extra attributes/methods you can use with the UIControl class to alter the resulting image.

tagged: svg image create dynamic tutorial example

Link:

DevX.com:
Add the Graphics Power of SVG to PHP
Feb 26, 2008 @ 16:44:00

In this DevX tutorial, Octavia Anghel shows how use PHP to create images based on the SVG libraries available to any browser.

Scalable Vector Graphics (SVG) is an XML specification for producing vector-based graphic content that you can create, modify, and manipulate dynamically from programming languages. Here, you'll explore the most important techniques and libraries for integrating SVG with PHP to create diverse graphic content—from simple shapes to complex graphs.

They show a few different ways to get the job done including a straight 'echo' call with the output, sending a converted SVG document over with a PHP header or including another (or multiple) SVG documents into another and outputting them. They also talk about tools like the phpHtmlLib library, the PEAR::XML_SVG package and the PEAR::Image_Canvas package.

tagged: svg graphic tutorial echo output include dynamic

Link:

Kore Nordmann's Blog:
Comparision of PHP image libraries
Dec 13, 2007 @ 18:07:00

Kore Nordmann has written up some benchmarks of some of the more popular PHP image creation libraries testing their output times and results for generating the same image.

In my article series I showed several ways on how to create images with PHP, going into implementation details etc. Now I just want to provide a very rough overview on speed and quality of the extensions.

He ran them with some settings disabled to optimize things as they ran and came up with results pointing to Cairo being the fastest to generate and output the image. It also had the benefit of outputting an image with the highest quality of the five tested (Cairo, SVG, Flash and GD with and without supersampling). His benchmark code is also included.

tagged: compare benchmark image library cairo svg flash gd compare benchmark image library cairo svg flash gd

Link:

Kore Nordmann's Blog:
Comparision of PHP image libraries
Dec 13, 2007 @ 18:07:00

Kore Nordmann has written up some benchmarks of some of the more popular PHP image creation libraries testing their output times and results for generating the same image.

In my article series I showed several ways on how to create images with PHP, going into implementation details etc. Now I just want to provide a very rough overview on speed and quality of the extensions.

He ran them with some settings disabled to optimize things as they ran and came up with results pointing to Cairo being the fastest to generate and output the image. It also had the benefit of outputting an image with the highest quality of the five tested (Cairo, SVG, Flash and GD with and without supersampling). His benchmark code is also included.

tagged: compare benchmark image library cairo svg flash gd compare benchmark image library cairo svg flash gd

Link:


Trending Topics: