I hope it helped. Feel free to comment...
Tuesday, April 12, 2011
Tuesday, April 5, 2011
SEO - Search Engine Optimization
To implement SEO - Search Engine Optimization correctly, we must broke it down into 2 factors;
I hope it helped. Feel free to comment...
Reference
http://www.wepapers.com/Papers/96414/Seo_Tutorial.pdf
- on-page criteria: <title>,<meta-description>,<h1>,<h2>,...,<h6>,<b>,<i>, keyword proximity, keyword density and relevance, etc...
- off-page criteria: links (in pages within our website and pages of other websites) that point to our specific pages. The terms "Page Rank" is used to weight and evaluate off-page criteria. Special attention should be given to: anchor text, reference_tags, "title" attribute and "target_"
I hope it helped. Feel free to comment...
Reference
http://www.wepapers.com/Papers/96414/Seo_Tutorial.pdf
URL shortener - Convert long URL into short URL
When it comes to URL shorteners, fewer letters are always best. x.co is one of the shortest, publicly-accessible shortening applications around.
Go ahead to x.co, just copy and paste a long URL into the box, then use the neat little URL we provide in your Twitter or Facebook posts, comments, emails, blog posts - wherever you like.
I hope it helped. Feel free to comment...
Friday, April 1, 2011
Create thumbnails of jpeg, gif, png images using PHP script
<?php
/*------------------------------------------------------------*/
//Author: Raju Rajpurohit
//Purpose: Function create the absobulate image (thumb image)
//$image = name of the original image
//$new_image_name = new name of image
//$width = width of image as you required
//$height = height of image as you required
//$fs_path = path where the file will be saved or located the original file
/*------------------------------------------------------------*/
define("JPEGQUALITY", 95);
function create_abs_image($image, $new_image_name, $width, $height, $fs_path, $aspectratio=1, $resize=1)
{
$src = $fs_path . $image;
if($imagedata = @getimagesize($src))
{
define(JPEGQUALITY, 95);//define the quality of JPG thumbnails
error_reporting(0);
$types = array (1 => "gif", "jpeg", "png", "swf", "psd", "wbmp");
$not_supported_formats = array("PSD");//write ext in capital letter
umask(0);
if(!$imagedata[2] || $imagedata[2] == 4 || $imagedata[2] == 5){
die('The specified file is not a picture!');
}
$imgtype = "!(ImageTypes() & IMG_" . strtoupper($types[$imagedata[2]]) . ")";
if((eval($imgtype)) || (in_array(strtoupper(array_pop(explode('.', basename($src)))),$not_supported_formats))) {
$src = substr ($src, (strrpos ($fs_path . '/', '/'))+1);
return $src;
}
if(!isset ($width)) $width = floor ($height * $imagedata[0] / $imagedata[1]);
if(!isset ($height)) $height = floor ($width * $imagedata[1] / $imagedata[0]);
if ($aspectratio && isset ($width) && isset ($height))
{
if ((($imagedata[1]/$height) > ($imagedata[0]/$width) ))
{
$width = ceil(($imagedata[0]/$imagedata[1])* $height);
} else {
$height = ceil($width/($imagedata[0]/$imagedata[1]));
}
}
$thumbfile = basename($new_image_name);
$calc_x = ($imagedata[0] < $width ? $imagedata[0] : $width);
$calc_y = ($imagedata[1] < $height ? $imagedata[1] : $height);
if(($imagedata[0] > $width || $imagedata[1] > $height) || (($imagedata[0] < $width || $imagedata[1] < $height) && $resize))
{
$makethumb = true;
}else{
$makethumb = false;
}
$width = $calc_x;
$height = $calc_y;
if ($makethumb)
{
$image = call_user_func("imagecreatefrom" . $types[$imagedata[2]], $src);
if(function_exists("imagecreatetruecolor") && ($thumb = imagecreatetruecolor($width, $height))){
imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $height, $imagedata[0], $imagedata[1]);
}else{
$thumb = imagecreate ($width, $height);
imagecopyresized ($thumb, $image, 0, 0, 0, 0, $width, $height, $imagedata[0], $imagedata[1]);
}
if ($types[$imagedata[2]] == "jpeg"){
call_user_func("image".$types[$imagedata[2]], $thumb, $fs_path.$thumbfile, JPEGQUALITY);
}else{
call_user_func("image".$types[$imagedata[2]], $thumb, $fs_path.$thumbfile);
}
imagedestroy ($image);
imagedestroy ($thumb);
}
}
}
$fs_root = $_SERVER['DOCUMENT_ROOT'] . '/';
create_abs_image('original_image.jpg', 'thumb.jpg', 50, 50, $fs_root);
?>
/*------------------------------------------------------------*/
//Author: Raju Rajpurohit
//Purpose: Function create the absobulate image (thumb image)
//$image = name of the original image
//$new_image_name = new name of image
//$width = width of image as you required
//$height = height of image as you required
//$fs_path = path where the file will be saved or located the original file
/*------------------------------------------------------------*/
define("JPEGQUALITY", 95);
function create_abs_image($image, $new_image_name, $width, $height, $fs_path, $aspectratio=1, $resize=1)
{
$src = $fs_path . $image;
if($imagedata = @getimagesize($src))
{
define(JPEGQUALITY, 95);//define the quality of JPG thumbnails
error_reporting(0);
$types = array (1 => "gif", "jpeg", "png", "swf", "psd", "wbmp");
$not_supported_formats = array("PSD");//write ext in capital letter
umask(0);
if(!$imagedata[2] || $imagedata[2] == 4 || $imagedata[2] == 5){
die('The specified file is not a picture!');
}
$imgtype = "!(ImageTypes() & IMG_" . strtoupper($types[$imagedata[2]]) . ")";
if((eval($imgtype)) || (in_array(strtoupper(array_pop(explode('.', basename($src)))),$not_supported_formats))) {
$src = substr ($src, (strrpos ($fs_path . '/', '/'))+1);
return $src;
}
if(!isset ($width)) $width = floor ($height * $imagedata[0] / $imagedata[1]);
if(!isset ($height)) $height = floor ($width * $imagedata[1] / $imagedata[0]);
if ($aspectratio && isset ($width) && isset ($height))
{
if ((($imagedata[1]/$height) > ($imagedata[0]/$width) ))
{
$width = ceil(($imagedata[0]/$imagedata[1])* $height);
} else {
$height = ceil($width/($imagedata[0]/$imagedata[1]));
}
}
$thumbfile = basename($new_image_name);
$calc_x = ($imagedata[0] < $width ? $imagedata[0] : $width);
$calc_y = ($imagedata[1] < $height ? $imagedata[1] : $height);
if(($imagedata[0] > $width || $imagedata[1] > $height) || (($imagedata[0] < $width || $imagedata[1] < $height) && $resize))
{
$makethumb = true;
}else{
$makethumb = false;
}
$width = $calc_x;
$height = $calc_y;
if ($makethumb)
{
$image = call_user_func("imagecreatefrom" . $types[$imagedata[2]], $src);
if(function_exists("imagecreatetruecolor") && ($thumb = imagecreatetruecolor($width, $height))){
imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $height, $imagedata[0], $imagedata[1]);
}else{
$thumb = imagecreate ($width, $height);
imagecopyresized ($thumb, $image, 0, 0, 0, 0, $width, $height, $imagedata[0], $imagedata[1]);
}
if ($types[$imagedata[2]] == "jpeg"){
call_user_func("image".$types[$imagedata[2]], $thumb, $fs_path.$thumbfile, JPEGQUALITY);
}else{
call_user_func("image".$types[$imagedata[2]], $thumb, $fs_path.$thumbfile);
}
imagedestroy ($image);
imagedestroy ($thumb);
}
}
}
$fs_root = $_SERVER['DOCUMENT_ROOT'] . '/';
create_abs_image('original_image.jpg', 'thumb.jpg', 50, 50, $fs_root);
?>
Copy paste the above code in a new php file and save the file in the www directory ( or htdocs for xampp).
Place the original picture in the same www or htdocs directory and replace original_image.jpg with the name of the original picture.
Now go to browser and run
http://localhost/filename.php
A new file thumb.jpg should be created in the www or htdocs directory.
I hope it helped... Please feel free to comment
Subscribe to:
Posts (Atom)