Alves Singh

/*
* $file = tmp_name of the image  ($_FILES[‘image’][‘tmp_name’];)
* $path = absolute path of the image (ABSPATH.’image/’;)
* $image_name = image name ($_FILES[‘image’][‘name’];)
* $size like Small< Large, Medium
* $file_type = file extension (
$type = $_FILES[‘image’][‘type’];
$image_type = explode(‘/’,$type);
)

How to use this function

$file         = $_FILES[‘profile_image’][‘tmp_name’];
$path         = IMAGE_DIR.’gallery/’;
$image_name = $general->uniqueName($_FILES[‘profile_image’][‘name’]);
$type         = $_FILES[‘profile_image’][‘type’];
$image_type    = explode(‘/’,$type);
$file_type  = $image_type[1];

$image = resize_crop_image($file,$path,$image_name,SMALL_IMAGE_WIDTH,SMALL_IMAGE_HEIGHT,’small’,$file_type);
*/
function resize_crop_image($file,$path,$image_name,$newwidth,$newheight,$prefix,$file_type=’jpeg’){
$uploadedfile     = $file;
$image_name     = $prefix.’_’.$image_name;
$src = @imagecreatefromjpeg($uploadedfile);
if($file_type==’jpeg’ OR $file_type==’jpg’){
$src = @imagecreatefromjpeg($uploadedfile);
}
if($file_type==’gif’){
$src = @imageCreateFromGif($uploadedfile);
}
if($file_type==’png’){
$src = @imageCreateFromPng($uploadedfile);
}
if($file_type==’bmp’){
$src = @imageCreateFromBmp($uploadedfile);
}
// Capture the original size of the uploaded image
list($width,$height)=getimagesize($uploadedfile);

$tmp     = @imagecreatetruecolor($newwidth,$newheight);

// this line actually does the image resizing, copying from the original
// image into the $tmp image
@imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);

// now write the resized image…

View original post 47 more words

Advertisements

9 thoughts on “

  1. Hello there, There’s no doubt that your website may be having internet browser compatibility issues. When I take a look at your site in Safari, it looks fine however when opening in I.E., it’s got some overlapping issues.

    I merely wanted to give you a quick heads up! Apart from that, fantastic site!

  2. Heya i’m for the first time here. I found this board and I in finding It really helpful & it helped me out a lot. I’m hoping to give something again and aid others like you aided me.

  3. I loved as much as you’ll receive carried out right here. The sketch is attractive, your authored subject matter stylish. nonetheless, you command get got an nervousness over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly very often inside case you shield this increase.

  4. Do you mind if I quote a couple of your posts as long as I provide credit
    and sources back to your blog? My blog site is in the exact same niche as
    yours and my users would really benefit from a lot of the information you present here.

    Please let me know if this okay with you. Thanks a lot!

  5. At this time it seems like BlogEngine is the best blogging platform
    available right now. (from what I’ve read) Is that what you are using on your blog?

  6. I believe that is one of the such a lot important info for me.
    And i am glad reading your article. But wanna statement on few basic issues, The site style is perfect,
    the articles is actually great : D. Just right activity,
    cheers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s