GIF, JPEG, and PNG: What’s The Difference?

Not a graphic designer? No problem! You can still easily master when to use different types of images for different purposes just by understanding some of their individual benefits! So find out below what each image type is good for:

GIF: Graphics Interchange Format
Images with a .gif extension are commonly used for the web because they compress quite well. They function by allowing you to restrict the number of colors that make up the image, with a maximum of 256 allowed. GIF images also allow for layering, which is commonly used to create moving images that you may often see in the form of internet ads or moving smiley faces. GIF images also allow for transparency so that items can be seen that appear beneath them.

JPEG: Joint Photographic Experts Group
Images ending in a .jpg or .jpeg extension are the most versatile images around. They have different levels of compression and are compatible with both RBG and CMYK color formats, making them suitable for both web and print. They have no color limitations, which can make their file sizes much larger than GIFs.

PNG: Portable Network Graphics
Images ending in .png only allow the RGB color format, meaning they are not suitable for print. Their biggest benefit is fantastic transparency capabilities that GIF images can’t match. They also tend to have a large file sizes because their compression isn’t always as successful as that of GIFs or JPEGs.

To help you decide what format to use for your images, try out this table:

Image Description GIF JPEG PNG
Black & White Photo X
Full Color Photo X
Black & White image for print X X
Color image for print X
Small Icon X
Image w/ just text X X
Moving image X
Image w/ complex transparency
i.e. curved lines or drop shadows
X
Image w/ simple transparency
i.e. straight lines
X

If you have any specific questions or examples you’d like to ask about, don’t hesitate to ask!

Javascript: Creating a Text Watermark

UPDATE: Read about the JQuery version of this text watermark.

This post is in response to a request to see how to create a textbox watermark using only text instead of an image. In a previous post, I explained how to use an image for a textbox watermark. Textbox watermarks are fantastic tools you can use to improve the usability of a website, as they give the user guidance on what to enter into the textbox. If you don’t want to use an image as my other post describes, here is how to create a simple watermark using javascript. Before we begin though, see exactly what you are making:

So either in an external Javascript file (which is called the same way as an external CSS file), or in the head of your HTML inside a <script> tag, include the following javascript:

The Javascript:

function watermark(inputId,text){
  var inputBox = document.getElementById(inputId);
    if (inputBox.value.length > 0){
      if (inputBox.value == text)
        inputBox.value = '';
    }
    else
      inputBox.value = text;
}

This javascript function checks if the textbox text isn’t empty, and then determines whether to clear the text or not. It also will put the watermark text back in if the user deletes what they entered or doesn’t enter anything. The function needs to be called in both the onblur and onfocus events of the textbox, which is explained below.

Here is the HTML that goes with the JS:

<input id="inputTextboxId" type="text" value="type here" onfocus="watermark('inputTextboxId','type here');" onblur="watermark('inputTextboxId','type here');" />

That’s all you need! And if you have any questions, don’t hesitate to ask! A question on my image watermark post lead to this post, so you never know!

WordPress: A Content Management System

There are a whole slew of reasons why WordPress has got to be the best blogging software out there. If you ask me however, WordPress’ ability to serve as a very functional, simply implemented, and relatively robust CMS (Content Management System) takes the cake. I was introduced to this concept by a pretty good blog article which got me started in my first full site installation. This article will walk you through the basic steps you’ll need to use WordPress as a content management system for your tech savvy self or for your non-techie clients.

The first step is to understand what WordPress can do. WordPress, which started out as just a blogging software, has expanded to include both posts (on a blog) and pages (like an about us page, or contact us page). In addition to that, WordPress is open source (which means that the code that creates it is public) allowing for people to create additions to it called plugins. These plugins do pretty much everything you can imagine like create a contact form, display google calendar events, create flickr photo arrays, or show youtube videos. With this software, you can make incredibly complex sites, with lots of ease, and simple site management capabilities.

So here are the steps to setting up WordPress as a CMS for a website. First you’ve got to install wordpress in the root directory of your site. If you were using wordpress just for blogging, you might install it inside of a folder called “blog”, but you’ll be using it for everything, including your homepage, so root it is. Second, after your installation is complete including database setup and the like, visit http://yoursite.com/wp-admin/, login using the admin information you setup during installation, and visit the “pages” section on the left navigation. You’ll want to add TWO pages. Call one of them “Home” with a permalink of just your root address, and the other whatever you want (if you are including a blog on this site, then perhaps create that page, if not, just do an about us page or something). Third visit “Settings > Reading” on the left navigation. With two pages already created, you’ll be able to set the front page as “Home”, and if you are including a blog, that page as your posts page.

That was the initial and easy walkthrough. With those three steps, you’ve already successfully setup your site to have pages, with a homepage, and a blog as a subsection of your site. Outside of obviously editing your theme to work with your design, you may also want to install some plugins to make managing the site more convenient for non-tech people. There are prebuilt plugins for youtube, flickr, google maps, google calendar, facebook, twitter, and most other platforms that you or your client may already be using.

If you have any questions, don’t hesitate to ask. The link in the beginning of this article discusses a lot of good plugins that you might find helpful, though the article is a little outdated and may be lacking on newer plugins. For example sites that use wordpress as a CMS and blog, check out this site or one of my clients. Good luck!

AJAX: Loading External Content

Asynchronous Javascript and XML, is a method used to communicate with the server and load new content in a website without having to reload the page. You’ve probably seen it all over the web, and now you are going to learn how to implement it yourself!

Step 1: Install JQuery: Not sure what jquery is? It is basically a bunch a prebuilt javascript to make your life a whole lot easier. Go to http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.2.min.js to download the most stable version of JQuery as of this post publishing date (1.3.2) or http://jquery.com/ for the most recent version (1.4.2).

Step 2: Install JQuery UI For Better Animations (optional): I highly advise using some animations to spice up the interaction of your AJAX. When a user clicks something that fires your AJAX, they want to know something is happening. If it happens too quickly, they won’t know, so we’ll actually have to slow it down a bit for them. Visit http://jqueryui.com/download to download the UI components if you’d like these better animations. I advise the “core”, the “effects core”, and the “effects blind”. You can try other effects as well such as “fold” if you want a different visual.

Step 3: Make Two Different Pages: The concept of AJAX relies on the existence of two files. The first file is a normal webpage that will contain whatever you want to reload. The second file should use HTML, but not be contained within any html or body tags. The reason for this is your the javascript you are about to create will be loading the entire second document literally within the first document. You can’t have two html or body tags, so don’t use them! Having trouble understanding, well how about an example.  Say you are creating a search feature on your site. The first document is the actual search page that contains the search bar and submit button (say http://samplesite.com/search.html). The second document will hold the results of the search that was submitted on the first page and usually takes some sort of arguments, variables, query strings, or whatever else you’d like to call them (in the case of this example, probably the search terms entered in the search bar).

The HTML for the first document (front-facing):

<img id="loadImg" src="animatedGifLocation" alt="Loading..." />
<div id="opacityWrap"><div id="fillBox"></div></div>
<input id="queryField" type="text" value="" />
<input id="submitQueryButton" type="button" value="Submit Query" />

The PHP for the second document (hidden from users):

<?php
  $textBoxContent = $_GET['data'];
  echo ("<p>".$textBoxContent."</p>");
?>

Step 4: Write Some Javascript: Using some preexisting jquery functions, all we have to do is throw together a simple function that is called on the button click (or whatever else works for your particular situation). This particular javascript below uses an animated gif to indicate loading and a div two grey out the loading content box.

$("#submitQueryButton").click(function() {
  $("#opacityWrap").animate({ opacity: .15 }, 100);
  $("#loadImg").show();
  $("#fillBox").load("secondPageURLhere?query=" + $("#queryField").val(),function() {
    $("#loadImg").hide();
    $("#opacityWrap").animate({ opacity: 1.0 }, 100);
  });
});

Step 5: See It In Action:

Loading...

Dependent on whether you enter a number or a word into the text box, different content will load here. The button calls an AJAX function that loads another page. This page, dependent on the request sent by the AJAX, outputs the page’s determination of what you entered.

The most useful time for this implementation of AJAX is when you want to communicate with your database to load content that your already rendered page doesn’t have. This particular example does not actually use any information from a database, but it should get the point across. So now that you know how to implement this, go and do it! Ask questions if you got ‘em.

AJAX: Wait Here Just A Minute

The best thing about Ajax is you can get brand new content on a page without having to reload it. The worst thing about ajax is people aren’t entirely used to waiting for content if they don’t see a page reload. Well, there is a quick and easy solution for that problem: animated gifs! In the beginnings of the web, animated gifs were used to make flashing titles that somehow everyone thought were the bee’s knees. Now that those are thankfully out of fashion, we can use animated gifs as an indicator that the website is “thinking”. The average web user won’t understand what all this AJAX stuff is doing in the background, all they need is something to tell them to wait just a little bit. Here are a few examples that I created using an awesome AJAX loading gif generator:

Oooh, that’s pretty. But maybe something more simple?

I like the simplicity, but it is too circly. Fix it designer!

And here’s a bar that could be used to indicate more of a “progress” concept instead of a “loading” concept:

I can guarantee that you’ve seen these types of images all over the web, and now you know why. It is possible people will implement these animated gifs for other purposes, but mostly, you’ll just experience them because of AJAX. Now go have fun making your own!