Image Compression Tool
- Allowed image types are -- .jpg|.jpeg|.gif|.png.
0) {
echo '
Increase post_max_size and upload_max_filesize limit in php.ini file.
'; } else { if($_FILES['uploadImg']['size'] / 1024 <= 5120) { // 5MB if($_FILES['uploadImg']['type'] == 'image/jpeg' || $_FILES['uploadImg']['type'] == 'image/pjpeg' || $_FILES['uploadImg']['type'] == 'image/png' || $_FILES['uploadImg']['type'] == 'image/gif'){ $source_file = $_FILES['uploadImg']['tmp_name']; $target_file = "uploads/compressed_" . $_FILES['uploadImg']['name']; $width = $_POST['width']; $height = $_POST['height']; $quality = $_POST['quality']; //$image_name = $_FILES['uploadImg']['name']; $success = compress_image($source_file, $target_file, $width, $height, $quality); if($success) { // Optional. The original file is uploaded to the server only for the comparison purpose. copy($source_file, "uploads/original_" . $_FILES['uploadImg']['name']); } } } else { echo 'Image should be maximun 5MB in size!
'; } } } else { echo "Please select an image first!
"; } } ?>
" target="_blank" title="View actual size">
Original : KB |
" target="_blank" title="View actual size">
Compressed : KB |
Not supported file type!
"; break; } } } ?>
Newest
Previous
Next Post »
Next Post »
ConversionConversion EmoticonEmoticon