Skip to main content

How To Resize Image In Php Codeigniter-Codeigniter Framework Me Image Kaise Compress Kare


compress image file size without losing quality in php



Upload And Resize Image Using Codeigniter-

Hello Friends Is Post Me Apko Btaunga Ki Kis Parkar Ham Codeigniter Framework Me Image Size Reduce Kar Sakte Hai .
Aap Niche Diye Gye Steps Ko Follow Kijiye-
Note-Sabse Pehle Aap apne Root Folder Ke Ander Uploads Name Ka Folder Create Kar Lijiye.
ü  Sabse Pehle Aap Ek upload.php Name Ki File Create Kar Lijiye Apne Codeigniter Ke Controller Folder  Me.Ham Ye Be Keh Sakte Hai Ki Aap Upload Name Ka Ek Controller Bana Lijiye
And Us File Me Niche Diye Gye Code Ko Paste Kar Diiye
upload.php





<?php



class Upload extends CI_Controller {



function __construct()

{

parent::__construct();



$this->load->helper(array('form', 'url'));

$this->load->library('image_lib');

$this->load->model('Hello_Model');

}



function index()

{

$this->load->view('upload_form', array('error' => ' ' ));

}



function do_upload()

{

$config['upload_path'] = './uploads/';

$config['allowed_types'] = 'gif|jpg|png';

$config['max_size'] = '1000';

$config['max_width']  = '1024';

$config['max_height']  = '768';



$this->load->library('upload', $config);



if ( ! $this->upload->do_upload())

{

$error = array('error' => $this->upload->display_errors());



$this->load->view('upload_form', $error);

}

else

{



$data = array('upload_data' => $this->upload->data());

$this->resize($data['upload_data']['full_path'], $data['upload_data']['file_name']);



$this->load->view('upload_success', $data);

}

}


function resize($path,$file)

{

$config['image_library']='gd2';

$config['source_image']=$path;

$config['create_thumb']=TRUE;

$config['maintain_ratio']=TRUE;

$config['width']=150;

$config['height']=75;

$config['new_image']='./uploads/'.$file;

$this->image_lib->initialize($config);

$this->image_lib->resize();


}

}



?>


ü  Ab Aap Ek  upload_form.php Name Ki File Create Kijiye View Folder Ke Ander
ü  Wanha Ye Code Paste Karke Save Kar Dijiye
upload_form.php











<center>



<html>

<head>

<title>Upload Form</title>

<style>



body{



background-repeat: no-repeat;





}





body {font-family: Arial, Helvetica, sans-serif;}



/* The Modal (background) */

.modal {

    display: none; /* Hidden by default */

    position: fixed; /* Stay in place */

    z-index: 1; /* Sit on top */

    padding-top: 100px; /* Location of the box */

    left: 0;

    top: 0;

    width: 100%; /* Full width */

    height: 100%; /* Full height */

    overflow: auto; /* Enable scroll if needed */

    background-color: rgb(0,0,0); /* Fallback color */

    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */

}



/* Modal Content */

.modal-content {

    background-color: #fefefe;

    margin: auto;

    padding: 20px;

    border: 1px solid #888;

    width: 80%;

/*background-image:url("monu.png"); */

}



/* The Close Button */

.close {

    color: #aaaaaa;

    float: right;

    font-size: 28px;

    font-weight: bold;

}



.close:hover,

.close:focus {

    color: #000;

    text-decoration: none;

    cursor: pointer;

}



</style>



</head>

<body>







<center>

<h2>Image Size Reduce In Php</h2>



<!-- Trigger/Open The Modal -->

<button id="myBtn">Reduce  Image Size</button>

<center>

<!-- The Modal -->

<div id="mymodal1" class="modal">



  <!-- Modal content -->

  <div class="modal-content">

    <span class="close">×</span>

    <p>Some text in the Modal..</p>







<center>







<?php echo $error;?>



<?php echo form_open_multipart('upload/do_upload');?>









<input type="file" name="userfile" size="20" />



<br /><br />



<input type="submit" value="upload" />



</form>

</div>

</div>

<script>

// Get the modal

var modal = document.getElementById('mymodal1');



// Get the button that opens the modal

var btn = document.getElementById("myBtn");



// Get the <span> element that closes the modal

var span = document.getElementsByClassName("close")[0];



// When the user clicks the button, open the modal

btn.onclick = function() {

    modal.style.display = "block";

}



// When the user clicks on <span> (x), close the modal

span.onclick = function() {

    modal.style.display = "none";

}



// When the user clicks anywhere outside of the modal, close it

window.onclick = function(event) {

    if (event.target == modal) {

        modal.style.display = "none";

    }

}

</script>



</body>

</html>

</center>



ü  Ab Ek  form_success .php Name ki Ek File View folder ke ander Create kar lijiye

form_success.php 





<center>



<html>

<head>

<title>Upload Form</title>

<style>



body{



background-repeat: no-repeat;





}





body {font-family: Arial, Helvetica, sans-serif;}



/* The Modal (background) */

.modal {

    display: none; /* Hidden by default */

    position: fixed; /* Stay in place */

    z-index: 1; /* Sit on top */

    padding-top: 100px; /* Location of the box */

    left: 0;

    top: 0;

    width: 100%; /* Full width */

    height: 100%; /* Full height */

    overflow: auto; /* Enable scroll if needed */

    background-color: rgb(0,0,0); /* Fallback color */

    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */

}



/* Modal Content */

.modal-content {

    background-color: #fefefe;

    margin: auto;

    padding: 20px;

    border: 1px solid #888;

    width: 80%;

/*background-image:url("monu.png"); */

}



/* The Close Button */

.close {

    color: #aaaaaa;

    float: right;

    font-size: 28px;

    font-weight: bold;

}



.close:hover,

.close:focus {

    color: #000;

    text-decoration: none;

    cursor: pointer;

}



</style>



</head>

<body>







<center>

<h2>Image Size Reduce In Php</h2>



<!-- Trigger/Open The Modal -->

<button id="myBtn">Reduce  Image Size</button>

<center>

<!-- The Modal -->

<div id="mymodal1" class="modal">



  <!-- Modal content -->

  <div class="modal-content">

    <span class="close">×</span>

    <p>Some text in the Modal..</p>







<center>







<?php echo $error;?>



<?php echo form_open_multipart('upload/do_upload');?>









<input type="file" name="userfile" size="20" />



<br /><br />



<input type="submit" value="upload" />



</form>

</div>

</div>

<script>

// Get the modal

var modal = document.getElementById('mymodal1');



// Get the button that opens the modal

var btn = document.getElementById("myBtn");



// Get the <span> element that closes the modal

var span = document.getElementsByClassName("close")[0];



// When the user clicks the button, open the modal

btn.onclick = function() {

    modal.style.display = "block";

}



// When the user clicks on <span> (x), close the modal

span.onclick = function() {

    modal.style.display = "none";

}



// When the user clicks anywhere outside of the modal, close it

window.onclick = function(event) {

    if (event.target == modal) {

        modal.style.display = "none";

    }

}

</script>



</body>

</html>

</center>

http://localhost/yourprojectname /index.php/upload/index
Is Url Kobowser Me Enter Karke Aap Is Code Ko Run Karwake Apni Image Ka Size Reduce Karwa Sakte Ho.

Resize Image Without Stretching In Codeigniter-


Ab Aap Apne Is Script Ko Run Karwakar Dekh Sakte Ho Or Image Reduce Karwa Sakte Ho.Me Ummid Karta Hu Ki Apko Post Achi Lagi Hogi Agar Koi Problem A Rhe Hai To Comment Me Puch Sakte Hai Aap.
Thank You


Comments

  1. sir your blog and all article are nice keep it up

    ReplyDelete
  2. Gajabwap ek Acha Blog hai nice article

    ReplyDelete

Post a Comment

Popular posts from this blog

How to Download Vimeo Thumbnail With PHP

Vimeo Thumbnail Downloader Tool – Vimeo Video Ka Thumbnail Download Karein Aaj ke is tutorial mein hum Vimeo Thumbnail Downloader Tool ke baare mein jaanenge. Is tool ki help se hum Vimeo video URL se us video ki thumbnail image obtain kar sakte hain. Agar aap PHP, Web Development, HTML, CSS aur Online Tools banana seekh rahe hain, to ye ek useful PHP project example hai. Vimeo Thumbnail Downloader Kya Hai? Vimeo Thumbnail Downloader ek simple tool hai jisme user Vimeo video ka URL enter karta hai. Tool Vimeo video ID ko identify karta hai aur available thumbnail image ko display karta hai. Example Vimeo URL: https://vimeo.com/389063954 Is URL mein: 389063954 Vimeo video ID hai. Vimeo Thumbnail Downloader Kaise Work Karta Hai? Is PHP script mein mainly do functions use kiye gaye hain: 1. getVimeoId() Ye function Vimeo URL se video ID find karta hai. 2. getVimeoThumb() Ye function Vimeo video ID ke basis par thumbnail information retrieve karta hai aur available thumbnail...

How To Create Contact Form With Validation-Php & Html

How To Create Contact Form - Hello Friends Ajj Me Apko Btaunga   Ki Kis Prakar   Ham Apni Website Ke Liye Contact Form Bnana Sakta Hai.( By Using   Php Contact Form With Validation Script ) Contact Form Hmare Website Ke Liye Bhut He Jrruri Hota Hai.Contact Form Ke Help Se He User Apna Message Website Owner(Admin) Ko Bhej Sakte Hai. Ajj Me Apko Btane Wala Hu Ki Kis Parkar Ham Contact Form Banakar Apne Website Me Add Kar Sakte Hai Or Apni Website Ke Liye Contact Form Bana Sakte Hai Is Contact Form Me   Ham Php Mail Function() Ka Use Karege . Ab Jab Be Koi User Contact Form Me Apni Information ,Message Details Fill Karke Submit Karega To Uski Sare Information Website Admin Ke Email Id Par A Jaiyegi Jo Be Admin Dwara   Niche Diye Gye Code Me Setup Ki Hogi. Used Language- ·          HTML ·          Jquery ·          Php ...

How To Send Sms From Website Using Php-Textlocal SMS

Hello Friends Ajj Me Apko Btaunga Ki Kis Prakar Aap Apni Website Me Free Sms Send Ka Option Integrate Kar Sakte Ho. Bulk sms in India-Best company Iske Liye Apko Sabse Pehle   Https://Www.Textlocal.In/Signup Par Signup Karke Account Create Karna Hai.Ye Ek Achi bulk sms provider company hai ·          Account Create Hone Ke Bad Aap Apna Username And Password Enter Karke Apne Dashboard Me Login Ho Jaiye( textlocal login) ·          Yanha Apko Text Local Company Dwara 10 Meassge Free Testing Ke Liye Diye Jayege ·          Aap Sms Plan Buy Kar Sakte Ho Is Company Dwara Bhut He Kam Prize Me Sms Pakage,plan provide  Kiye Jate Hai Textlocal Price Plans –  index.php <?php if(isset($_POST['code']) &&  isset($_POST['mobile'])){ // Authorisation details. $username = "enter your textlocal account email id here"; $hash = "...