In this post you can find how to use Cropper.js library for Crop image before uploading of image to the server using PHP script. In this tutorial you can learn simple image crop while uploading of image using Cropper.js with PHP. If you are looking of tutorial on crop and save image using jQuery and PHP. Then you have come on the right web page, because in this blog we have step by step describe, how to use Cropper.js with PHP for crop image before upload image to the server. In this tutorial, we have use ajax for image upload and for crop, we have use jQuery and PHP.
In one of the our previous tutorial on image cropping and uploading to server, and in this tutorial, we have use Croppie.js library of Crop image at the time of uploading of image. But at that time many viewers has requested us to publish tutorial on how to crop image using Cropper.js library at the time of uploading of image using PHP. For that request we have publish this tutorial and in this we have implement how to use Cropper.js library for crop image dynamically while uploading of images. By using Cropper.js library you can do live crop of image, resize of image at the time of upload of image. In this post we have use Cropper.js jQuery plugin for Crop and Resize image, and for upload image to server here we have use Ajax with PHP.
There are many benefits of Cropping of image before upload image to server.
- Crop image is great feature for server space optimization.
- Crop image will resize image as per required size while uploading on the server.
- Crop image will reduce image size and optimize image before uploading to the server.
- Crop image will upload image with our required width and height.
- Crop image will reduce web page size and it will reduce loading time for display image.
- Crop image will optimize image data before uploaded to the server.
- Crop image will optimize image so it will save our bandwidth
- Crop image will make thumbnail of uploaded image
Cropper.js is simple jQuery plugin which has been used for image crop with extra functionality like live preview of image at the time of uploading of image. By using this plugin you can get the functionality like moving of image, zooming of image, rotating of image, and this plugin is fully responsive and it is mobile friendly. Crop image functionality, we can use in edit profile pictures, creating phone albums etc which we have upload to the server. Lastly, In this tutorial we will integrate Cropper.js with PHP script for optimize image by croping before image uploaded to the server. So In this tutorial, we will integrate Cropper.js for crop image while uploading of image using PHP script with Ajax.
Source Code
index.php
<?php
//index.php
?>
<!DOCTYPE html>
<html>
<head>
<title>Crop Image Before Upload using CropperJS with PHP</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/dropzone/dist/dropzone.css" />
<link href="https://unpkg.com/cropperjs/dist/cropper.css" rel="stylesheet"/>
<script src="https://unpkg.com/dropzone"></script>
<script src="https://unpkg.com/cropperjs"></script>
<style>
.image_area {
position: relative;
}
img {
display: block;
max-width: 100%;
}
.preview {
overflow: hidden;
width: 160px;
height: 160px;
margin: 10px;
border: 1px solid red;
}
.modal-lg{
max-width: 1000px !important;
}
.overlay {
position: absolute;
bottom: 10px;
left: 0;
right: 0;
background-color: rgba(255, 255, 255, 0.5);
overflow: hidden;
height: 0;
transition: .5s ease;
width: 100%;
}
.image_area:hover .overlay {
height: 50%;
cursor: pointer;
}
.text {
color: #333;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
</style>
</head>
<body>
<div class="container" align="center">
<br />
<h3 align="center">Crop Image Before Upload using CropperJS with PHP</h3>
<br />
<div class="row">
<div class="col-md-4"> </div>
<div class="col-md-4">
<div class="image_area">
<form method="post">
<label for="upload_image">
<img src="upload/user.png" id="uploaded_image" class="img-responsive img-circle" />
<div class="overlay">
<div class="text">Click to Change Profile Image</div>
</div>
<input type="file" name="image" class="image" id="upload_image" style="display:none" />
</label>
</form>
</div>
</div>
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Crop Image Before Upload</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="img-container">
<div class="row">
<div class="col-md-8">
<img src="" id="sample_image" />
</div>
<div class="col-md-4">
<div class="preview"></div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" id="crop" class="btn btn-primary">Crop</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function(){
var $modal = $('#modal');
var image = document.getElementById('sample_image');
var cropper;
$('#upload_image').change(function(event){
var files = event.target.files;
var done = function(url){
image.src = url;
$modal.modal('show');
};
if(files && files.length > 0)
{
reader = new FileReader();
reader.onload = function(event)
{
done(reader.result);
};
reader.readAsDataURL(files[0]);
}
});
$modal.on('shown.bs.modal', function() {
cropper = new Cropper(image, {
aspectRatio: 1,
viewMode: 3,
preview:'.preview'
});
}).on('hidden.bs.modal', function(){
cropper.destroy();
cropper = null;
});
$('#crop').click(function(){
canvas = cropper.getCroppedCanvas({
width:400,
height:400
});
canvas.toBlob(function(blob){
url = URL.createObjectURL(blob);
var reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function(){
var base64data = reader.result;
$.ajax({
url:'upload.php',
method:'POST',
data:{image:base64data},
success:function(data)
{
$modal.modal('hide');
$('#uploaded_image').attr('src', data);
}
});
};
});
});
});
</script>
upload.php
<?php
//upload.php
if(isset($_POST['image']))
{
$data = $_POST['image'];
////data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAC0CAIAAAA1l+0PAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAABk3SURBVHhe7Z1/iF5VesfnjyJM/3hLWJyhL13WQWGlKETYLVKEsF0WFTrSTZBaRIpdVrZZ2SZl0W4bdV3sgtsqMSC1RurWZNsSXImQqFXYCOLG/CErWUhapdHJTDNm4saEDJhJ0qTfc+/JzZ1zfz3Puee+73tevx++SJz3nvOee997vu9znvvc+05cIoSQSKBhEUKigYZFCIkGGhYhJBpoWISQaKBhEUKigYZFCIkGGhYhJBpoWISQaKBhEUKigYZFCIkGGhYhJBpoWISQaKBhEUKigYZFCIkGGhYhJBpoWISQaKBhETI+nF+Yv7h8xv7POELDImR8WFw/e/KJx+3/jCM0LELGhM8O7P9oYmJu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PpuxPRgKov+Sco4GBb+/vHdd2LyO00GoYJhqSYGxiwsTOvIsOQHDVvmZy/amsBHY1iSWtYiihoRqKz8ImXxjttUi0F0hRCy6pRzUFXJGaVXXWWdkzzjYFgp+CqWO0UwFQzrnObG7OEalgkGNYaVX9PZ7HVhsyoZw/KKKVS3NFiXKSzi1JmmZMDykFBxvfWysFOh7vr4XDE+hgVskkL1XddSSW1X3rBURYloG5Fh5YequsIIYWM/w9JWeyFyyX8cQBsMGunv/lNdMzVKsu/CSmaSMVaGBTCRcKqZuaQ6QbW6XM+F6YFv7/zAFNWYsRlWvmJAWyyOjf0MC19CKsOCnH1f1D+s3WO0WgeHMCpm37WMm2GlLL+yB0sDcwJpv1prlEwGTJ70vMQKtLRqWZWCjcmwVldgaBdB2Lj0cDWiNSyMM7/vPheRlU9GzdDeEQ1hbH6pvc8tAQwrTR4NQHLDSsGpkJ5DaGtOeg/zwvbJoi/t4djsrZi0+O51Fh150nSJXPWFjhnYEadhvSSGhW2cVvXKhwOpL6vkbVhOP43K1lnaHczkVJwJwVnh9CMRzqvGygmSEcCw8OniXByA7PspwWkEi4Ev4Gszu/kmO1fyyr+UCp4Fp8CcwbujH4ljYpLkx9woYRZDe5AlQ8U2Tqt65e/BxNFwXm2U37TUHk8oeyOPtqnS5h7gEDldSVTz/UccAhhWXGCWwiNgYVgsQAiIoPTfiBqM3tyHcwjnujagI4R0zefOsAgh8ULDIoREAw2LEBINNCxCSDTQsAgh0UDDIoREAw2LEBINNCxCSDTQsAgh0UDDIoREAw2LEBINNCxCSDTQsAgh0UDDIoREAw2LEBINNCxCSDTQsAgh0UDDIoREAw2LEBINNCxCSDTQsAgh0UDDIoREAw2LEBINNCxCSDTQsAgh0UDDIoREwqVL/w8KSyqJVFfZUwAAAABJRU5ErkJggg==
$data = base64_decode($image_array_2[1]);
$image_name = 'upload/' . time() . '.png';
file_put_contents($image_name, $data);
echo $image_name;
}
?>
Perfect - works great! I found it easiest to work with the "view source" on the "View Demo"
ReplyDeleteGreat job
ReplyDeletehello, how to upload as a jpg instead of a png?
ReplyDelete¿Do you a version in Javascript vanilla?
ReplyDeleteHello, I've just done that for the image upload. You can replace the jquery $.ajax with this:
Deletedata = new FormData();
data.set('image', base64data);
httpRequest = new XMLHttpRequest();
httpRequest.open('POST', 'upload.php', true);
httpRequest.send(data);
Hope I'm in any help. JQuery is a dependency that tends to be render blocking and slow down pagespeed scores. Thats why I don't want to use it.
Thanks!!
ReplyDeleteThanks for this amazing demo. If I select a portrait photo, it cuts off the top and botton - it seems to only handle landscape photos properly?
ReplyDeleteThanks!!!!!!
ReplyDeleteit is returing 303 status while i try to crop it ?
ReplyDeletecan be 2 things:
Delete1. by default images are saved to "upload" folder, you must create this folder
2. folder permission is not set properly, cropper needs read and write permission to the "upload" folder
good for nothing bitch
ReplyDeletehow to increase quality of pic
ReplyDeleteHow do I make it output a JPG instead of a PNG?
ReplyDelete$image_name = 'upload/' . time() . '.png';
DeleteIn this line, change the .png extension to jpg
How do I make it output a JPG with quality 75 instead of a PNG?
DeleteThank you very much! It works very fine.
ReplyDeleteBut I have a question.
when uploading cropped image to server, I want the value of the crop button in modal dialog to change to wait just like on the "View Demo". How can I do that ?
how to store crop image name
ReplyDeletethanyou for post
ReplyDeletesame i want to add in word press custom template ... please guide
Well Thank you very much for the code, It works but Is it safe, tring to filter it with in_array( after exploding the filetype). I just don't want a back-door named image.php.png on my website server. So is it safe?
ReplyDeleteAmazing demo, could you make a demo with Codeigniter framework?
ReplyDeleteHello my friend before thanks for script. Its working very good.
ReplyDeleteBut i have a question.
Can we define one image on the script. Im gonna use already uploaded image. if its possible can it start with defined image ( for example abc.jpg )