image

image

Creating A Thumbnail Of A Word Document With PHP And LiveDocx

Saturday, September 24, 2011 - 15:25

In any list of documents in a system it is a good idea to add some thumbnails of the document so that your users can get a quick overview of what a document looks like before downloading it. This is a good alternative to just displaying an icon of the document type.

Creating Word document icons is very simple thanks to a service called LiveDocx. LiveDocx was created as a web service to allow the easy creation of most document formats from a simple template. However, it is possible to send a normal Word document as the template file and get an image of the file in return.

Category: 

Desaturate Images With PHP

Tuesday, September 6, 2011 - 19:11

To desaturate an image means to remove all non-greyscale colours from it, essentially creating a black and white version. To do this you can use the function imagecopymergegray(), which is part of the GD image library. This function is a little difficult to figure out, but what is does is sample one image into another and optionally changing the amount of colours that are kept during the sampling process. The function can be made to sample just a section of the image, or the whole thing. The parameters of the function are as follows.

Category: 

Print Image With Fixed Aspect Ratio In PHP

Monday, September 20, 2010 - 10:33

When displaying images added by users it is quite often necessary to resize them in order that they fit into a specific area of the page. Not doing this can cause problems with the images breaking the page layout. The trouble is that if you resize the image absolutely you tend to squash and distort it.

The following function can be used to calculate the width and height of an image to the correct aspect ratio, which will preserve the contents when printed out. This function makes use of the getimagesize() function, which is available as part of the GD library in PHP.

Category: 

JQuery Image Switcher

Monday, December 7, 2009 - 21:40

Using something like CrossSlide is fine if you want fancy effects in your image translations, but for more simple effects you can use a single function to simply swap one image for another. First, lets create some simple markup that will allow us to display some images.

1
2
3
4
5
6
<div class="slideshow">
<img src="image1.png" alt="Image 1" />
<img src="image2.png" alt="Image 2" />
<img src="image3.png" alt="Image 3" />
<img src="image4.png" alt="Image 4" />
</div>
Category: 

Pixelate Images With PHP

Wednesday, June 3, 2009 - 21:19

The other day I needed to hide an image but keep the original image intact so rather than do complicated things with light and dark filters I decided the best way would be to pixelate the image. All that is required to pixelate an image is to shrink it down and then blow it up to the original size, thus reducing the quality of the image.

Category: 

Sequentially Rename All Image Files In A Directory With PHP

Monday, March 2, 2009 - 12:36

The following function will rename all of the image files in a directory to be sequential. The parameters are the path of the directory that the files are in and the name of a function that will be used to sort the array of files through the PHP usort() function.

Category: