Today I have been working on my butterfly tattoos website. There is a lot more to come on that website, I have ideas for Flickr integrations and more. At the moment I am getting c. 500 unique users a day passing through the site and I have made 0 changes since 2004. This site needs to be brought up to date. One way I am looking to do this is through enabling users to simply upload their own photographs (this will help me too since I have about 50 tattoos sitting ready to be uploaded). A key part of this is to do all the image handling on the server with pre-existing PHP functions. While working on this idea I found the following code source "create square image thumbnails with PHP".
This code uses the simple but very powerful GD graphics utilities that come with PHP 4 and 5. I have used them a lot and I won't reproduce his code here however I will show my use of the code. I create a function which I store in a seperate include and can be called any time. The function will return "none" if there has been no error or will return an error like "I don't support images of the type image/bmp support png, jpg and gif try converting to that and uploading" if an image format I don't support is sent.
function createThumb($source,$dest,$mimetype)
{
$thumb_size = 150;
$size = getimagesize($source);
$width = $size[0];
$height = $size[1];
if($width> $height)
{
$x = ceil(($width - $height) / 2 );
$width = $height;
}
elseif($height> $width)
{
$y = ceil(($height - $width) / 2);
$height = $width;
}
if ($mimetype == "image/jpeg" || $mimetype == "image/jpg")
{
// set up the image (note imagecreatetruecolor doesn't work for gif)
$new_im = ImageCreatetruecolor($thumb_size,$thumb_size);
// what is the input format, create from that
$im = imagecreatefromjpeg($source);
imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height);
// the 100 is the quality here, this is quite high
imagejpeg($new_im,$dest,100);$error = "none
return $error;
}
elseif ($mimetype == "image/png")
{
// set up the image (note imagecreatetruecolor doesn't work for gif)
$new_im = ImageCreatetruecolor($thumb_size,$thumb_size);
// what is the input format, create from that
$im = imagecreatefrompng($source);
imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height);
imagepng($new_im,$dest);$error = "none
return $error;
}
elseif ($mimetype == "image/gif")
{
// set up the image (note imagecreatetruecolor doesn't work for gif)
$new_im = ImageCreate($thumb_size,$thumb_size);
// what is the input format, create from that
$im = imagecreatefromgif($source);
imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height);
imagegif($new_im,$dest);
$error = "nonereturn $error;
}
else
{
$error = "I don't support images of the type $mimetype but I do support png, jpg and gif try converting to that and uploading";
return $error;
};
}
The best bit of this code in my opinion is the ability to crop the image to a square while maintaining aspect ratio. This is managed by the imagecopyresampled() php function.

The Power of Focussing on Something
Today's post is something that is very interesting to me. How you can acheive results by just shifting your focus. I have 3 main websites: cocktail making, paper airplanes and butterfly tattoos. A great set of comments on this can be found in the awesome book good to great in which particularly the discussion on Chrysler Acquiring Gulfstream is particularly enlightening. If you deviate from your core, if you look somewhere else than 100% at what is most important to you it will not succeed as well as when you have 100% focus on your most important project.
For me an example of this can be seen in the image below which is the % year on year growth rates for my website traffic and website revenue (I have removed actual amounts) and this graph is mid way through Nov. hence Nov 2006 not looking so great.
When I looked at this graph I was shocked (I first looked at it in March 2006) to see my revenue growth year on year had gone negative in Nov and Dec 2005 (actually first time in 10yrs of running my own websites). This corresponded with me planning and executing emigrating to the US in December 2006. After settling into the US things clearly recovered until March 2006. This was a huge month for me with my first major international summit (I was jointly responsible for running), the first class I taught at our marketing college (on internet marketing... it was awesome ;) ) and my parents visiting the US. My site growth then decelerated as did my revenue growth until the second summit of the year happened in July 2006. I took the second half of July 2006 off to enjoy myself and work on things I enjoyed. Since that date I have worked on my personal projects at home and not taken much work home with me. I have focussed at work more on 2 key projects which really matter to me (and I can't talk about here) and my site revenue growth (see blue bar above), my site traffic growth (see red bar) and my projects at work are going really well and even reaccelerating.
I did a lot of things to produce this reacceleration (I launched a cocktail widget, I totally recoded my cocktail site, I added videos to my paper airplanes site and more) but the key point is the focus and this is what I want to say. When you can contribute significant focus to something it will go better than with partial focus. I am now thinking about that a lot as I work and play.
November 18, 2006 in general comments, natural search | Permalink | Comments (0) | TrackBack (0)