Monthly Archives: May 2007

Square Images

Flickr.com when uploading an image, it provides a small thumbnail, but it does in a square image, this is of course almost impossible for any “normal” image, because most images are rectangular, and trying to make it square will give you an awful image as result.

But Flickr images are very good, so I did it in php the similar process, and I will explain below.

We will use this example image:
Square Images - Image Example

To create a square, we need to calculate the maximum square that fit on the image, this is the minimum size between height and width.
Square Images - Image Size

Next we create a square with that size, of course, we need to put in the center, because if not, the image could look very different to the original image.

Square Images - Square

This can be done easily with the following formula:

//if the square is adjusted to width
$remain = $height - $min_size;
$y = floor($remain / 2.0);
//if the square is adjusted to height like the example image
$remain = $width - $min_size;
$x = floor($remain / 2.0);

Square Images - Image Final

You can test on this site:
http://www.danguer.com/articles/images/square/

Or check the sources here (in txt):
http://www.danguer.com/articles/images/square/source

The code is in two files and another php file which uses the other two, the files are:

  • ImageHandler.php this class provides basic handling of images, like openning and saving
  • ImageSquare.php this class extends the basic ImageHandler and provides a convert function which makes the image into square
  • index.php display the form and when an image is uploaded, it create the new square image and display it directly.
Share

coLinux Debian Etch Image

I’ve using coLinux from about a year ago and I’m very impressed, but recently I had to use a lot of features of the newest Linux distros; the most used image in coLinux is the Debian Image, but that is the stable (sarge) and now is old in packages, the newest is Etch.

I tried several times to install from debian net install iso but I couldn’t, there were some tutorials but none of them were helpful, and I tried again to search debian etch on coLinux and I found a link to a mailing list:

http://www.nabble.com/Where-is-Debian-Etch-Root-Image–t3588257.html

In this page you will find a link to a small Debian Etch image you can download and is ready to use, create a bigger image and install all your packages and you will be as happy as me =).

Share