Resizing All Images in Directory

I need a script for resize all images in one directory. I have create thumbnails for a site. I have not so much time write these code. I found two different code and mixed them. I love PHP, it is very easy to solve problem with little scripts. If you resize in same directory it will be resize resized images. If you need in same directory, just resized for temp directory and move it to your real one.

  1. Resizing image with Php by Simon Jarvis
  2. Directory Listing by Spoono
<?
/*
* Class: SimpleImage, Author: Simon Jarvis, Copyright: 2006 Simon Jarvis, Date: 08/11/06
* Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
* See the GNU General Public License for more details: http://www.gnu.org/licenses/gpl.html
*/

class SimpleImage {
   var $image;
   var $image_type;

   function load($filename) {
      $image_info = getimagesize($filename);
      $this->image_type = $image_info[2];
      if( $this->image_type == IMAGETYPE_JPEG ) {
         $this->image = imagecreatefromjpeg($filename);
      } elseif( $this->image_type == IMAGETYPE_GIF ) {
         $this->image = imagecreatefromgif($filename);
      } elseif( $this->image_type == IMAGETYPE_PNG ) {
         $this->image = imagecreatefrompng($filename);
      }
   }
   function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this->image,$filename,$compression);
      } elseif( $image_type == IMAGETYPE_GIF ) {
         imagegif($this->image,$filename);
      } elseif( $image_type == IMAGETYPE_PNG ) {
         imagepng($this->image,$filename);
      }
      if( $permissions != null) {
         chmod($filename,$permissions);
      }
   }
   function output($image_type=IMAGETYPE_JPEG) {
      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this->image);
      } elseif( $image_type == IMAGETYPE_GIF ) {
         imagegif($this->image);
      } elseif( $image_type == IMAGETYPE_PNG ) {
         imagepng($this->image);
      }
   }
   function getWidth() {
      return imagesx($this->image);
   }
   function getHeight() {
      return imagesy($this->image);
   }
   function resizeToHeight($height) {
      $ratio = $height / $this->getHeight();
      $width = $this->getWidth() * $ratio;
      $this->resize($width,$height);
   }
   function resizeToWidth($width) {
      $ratio = $width / $this->getWidth();
      $height = $this->getheight() * $ratio;
      $this->resize($width,$height);
   }
   function scale($scale) {
      $width = $this->getWidth() * $scale/100;
      $height = $this->getheight() * $scale/100;
      $this->resize($width,$height);
   }
   function resize($width,$height) {
      $new_image = imagecreatetruecolor($width, $height);
      imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
      $this->image = $new_image;
   }
}
// End of SimpleImage class

/* Directory Listing
Source : http://www.spoono.com/php/tutorials/tutorial.php?id=10
*/

// Define the path as relative
$path = "/home/site/public_html/images/";

// Using the opendir function
$dir_handle = @opendir($path) or die("ERROR: Cannot open  <b>$path</b>");

echo("Directory Listing of $path<br/>");

//running the while loop
while ($file = readdir($dir_handle))
{
   if($file != "." && $file != "..")
   {
	$image = new SimpleImage();
	$image->load("images/".$file);
	$image->resize(80,60);
	$image->save("images2/mini_".$file);
	echo("&bull; $file <br>");
   }
}

//closing the directory
closedir($dir_handle);
?>
Share and Enjoy:
  • StumbleUpon
  • Digg
  • TwitThis
  • FriendFeed
  • del.icio.us
  • MySpace
  • Technorati
  • Facebook
  • Google Bookmarks
  • Live

Google Announce Chromium OS Project

Today Google released Chromium OS, the open source project behind Google Chrome OS. Google Chrome OS is an operating system that is intended for people who spend most of their time on the web. It aims to provide a computing experience that is fast, simple and secure. The Chromium OS project as you’ll see it today is comprised of the code that has been developed thus far, our early experiments with the user interface, and detailed design docs for many parts that are under active development.

Fore more information and announcement:

http://chrome.blogspot.com/2009/11/announcing-chromium-os-open-source.html
http://googletesting.blogspot.com/2009/11/testing-chrome-os.html

Share and Enjoy:
  • StumbleUpon
  • Digg
  • TwitThis
  • FriendFeed
  • del.icio.us
  • MySpace
  • Technorati
  • Facebook
  • Google Bookmarks
  • Live

Google Create New Programming Language : GO

Google Engineers create new programming language “Go”. In first look it is look like C++ or Java. We will see, how it will be.

More details :
http://www.golang.me/google-launches-its-own-programming-language-go/

Share and Enjoy:
  • StumbleUpon
  • Digg
  • TwitThis
  • FriendFeed
  • del.icio.us
  • MySpace
  • Technorati
  • Facebook
  • Google Bookmarks
  • Live

Turn Off Autocomplete Form in Internet Explorer

A webmastersucks user ask me “The only problem is that IE will store the MD5 ] password when it “saves” the password. Have you been able to overcome that?”. Solution is really simple, just we can use autocomplete attribute in form tag. It will be close autocomplete in form. It will better in password protected sites.

<form name="form" method="post" autocomplete="off">....</form>
Share and Enjoy:
  • StumbleUpon
  • Digg
  • TwitThis
  • FriendFeed
  • del.icio.us
  • MySpace
  • Technorati
  • Facebook
  • Google Bookmarks
  • Live

Grouping Date with Datetime in MySQL

This is very basic and very useful command for mysql. I need user registration date by date. Firstly, i calculate with PHP, after i think it must be a basic way. I found this mysql command. I hope you’ll enjoy.

SELECT DATE_FORMAT(registerdate, '%Y-%m-%d') AS dd, COUNT(id) as TotalUser FROM UserTable GROUP BY dd;
Share and Enjoy:
  • StumbleUpon
  • Digg
  • TwitThis
  • FriendFeed
  • del.icio.us
  • MySpace
  • Technorati
  • Facebook
  • Google Bookmarks
  • Live

Unique Email Address in Mysql

I have a big mail database but there are some dublicate email addresses. I need unique email address lists and i follow this way;

Firstly i create temporary table for unique email address

CREATE  TABLE  mail_temp (  `email` varchar( 255  )  NOT  NULL default  ''

) ENGINE  =  MyISAM;

After i add unique email address to that temp table

INSERT INTO mail_temp SELECT DISTINCT(email) FROM mail_table

I dropped my real email table

DROP TABLE mail_table;

After all, i create new mail table and moved the temporary mail table to in.

CREATE TABLE mail_table( `email` varchar( 255 ) NOT NULL default ''
) ENGINE  = MyISAM;

INSERT INTO mail_table SELECT  DISTINCT(email) FROM mail_temp;

DROP TABLE mail_temp;
Share and Enjoy:
  • StumbleUpon
  • Digg
  • TwitThis
  • FriendFeed
  • del.icio.us
  • MySpace
  • Technorati
  • Facebook
  • Google Bookmarks
  • Live

Select Users Age in MySQL

SELECT count(id) AS toplam,YEAR(tarih_dogum) AS YIL FROM uyeler GROUP BY YEAR(tarih_dogum)

Advertising agencies wants to user profile for advertisements. I need my users age. I found a little solution. I write this SQL statement for select which year my users born and group them.

SELECT count(id) AS total,YEAR(birthday) AS birth_year FROM users GROUP BY YEAR(birthday);
After i copied this results to Excel. I calculate age groups like “18-24 years old” in Excel and send my offer to agencies.
Share and Enjoy:
  • StumbleUpon
  • Digg
  • TwitThis
  • FriendFeed
  • del.icio.us
  • MySpace
  • Technorati
  • Facebook
  • Google Bookmarks
  • Live

Follow Me at Twitter

I search for twitter follow me icons. I found a web site which is listed 31 logos for this. I hope you’ll enjoy..

http://www.vincentabry.com/31-logos-et-boutons-pour-twitter-2480

Share and Enjoy:
  • StumbleUpon
  • Digg
  • TwitThis
  • FriendFeed
  • del.icio.us
  • MySpace
  • Technorati
  • Facebook
  • Google Bookmarks
  • Live

BBPress is Forum of WordPress

I create a new web site about “The Martial Arts” with Wordpress. I want to create a forum work with WordPress together. I remember WordPress team works on forum software. They called “BBPress“. I install BBPress and it is asked me some WordPress questions about config file, i set them and i have got forum integrated with WordPress. Users are same in forum and WordPress. I suggest you BBPress if you are using Wordpress and want basic forum. BBPress is better in SEO. It is always come with its own seo system like wordpress. Here is my forum >

Read Config File to install BB Press

define('AUTH_KEY', 'aaaaa');

define('SECURE_AUTH_KEY', 'bbbbb');

define('LOGGED_IN_KEY', 'ccccc');

define('NONCE_KEY', 'ddddd');
define(‘AUTH_KEY’, ‘Martial1′);
define(‘SECURE_AUTH_KEY’, ‘Martial2′);
define(‘LOGGED_IN_KEY’, ‘Martial3′);
define(‘NONCE_KEY’, ‘Martial4′);
Share and Enjoy:
  • StumbleUpon
  • Digg
  • TwitThis
  • FriendFeed
  • del.icio.us
  • MySpace
  • Technorati
  • Facebook
  • Google Bookmarks
  • Live

FCK Editor is Reloaded: CK Editor

I always use FCK Editor in my php codes, it is really helpful for coding. 10 days ago FCK Editor is reloaded and change its name to CK Editor. There is lots of changing.

New Version of FCK Editor (CK Editor 3.0)

  • Working on Chrome clearly
  • It’s faster and faster
  • Better user interface
  • New javascript API
  • Work with php, asp, asp.net,Coldfusion

Download CK Editor >

Demo CK Editor >

Share and Enjoy:
  • StumbleUpon
  • Digg
  • TwitThis
  • FriendFeed
  • del.icio.us
  • MySpace
  • Technorati
  • Facebook
  • Google Bookmarks
  • Live