Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTB-24 added Image Base64 Conversion #35

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions shared/config/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,21 @@
"description": "Generates a Random Color",
"bgclass": "bg-warning",
"content": "./tools/randomColorGenerator.php"
},
},
{
"name": "base64Encode",
"displayname": "base64 Encoder",
"icon": "fa-solid fa-arrow-right-to-bracket",
"description": "Encodes a String to Base64",
"bgclass": "bg-success",
"bgclass": "bg-info",
"content": "./tools/base64encode.php"
},
{
"name": "base64Decode",
"displayname": "base64 Decodeder",
"icon": "fa-solid fa-arrow-right-from-bracket",
"description": "Decodes a String to Base64",
"bgclass": "bg-danger",
"description": "Decodes Base64 to a String",
"bgclass": "bg-info",
"content": "./tools/base64decode.php"
},
{
Expand Down Expand Up @@ -223,6 +223,23 @@
"bgclass": "bg-primary",
"content": "./tools/calculateTimeSinceDate.php"
},

{
"name": "base64ImageEncode",
"displayname": "Image to base64",
"icon": "fa-solid fa-arrow-right-to-bracket",
"description": "Encodes a Image to Base64",
"bgclass": "bg-info",
"content": "./tools/base64ImageEncode.php"
},
{
"name": "base64ImageDecode",
"displayname": "base64 to Image",
"icon": "fa-solid fa-arrow-right-from-bracket",
"description": "Decodes Base64 to a Image",
"bgclass": "bg-info",
"content": "./tools/base64ImageDecode.php"
},
{
"name": "getMetar",
"displayname": "Get Metar Weather for ICAO Code",
Expand Down
11 changes: 11 additions & 0 deletions tools/base64ImageDecode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<textarea class="form-control" id="image_input"></textarea>
<br><br>
<button class="btn btn-success" onclick="setImage()"><i class="fa-solid fa-gears"></i> Generate</button>
<br><br>
<img id="image_output_image" style="display:none;" width="100%" alt="Generated Image">
<script>
function setImage(){
$("#image_output_image")[0].src = $("#image_input")[0].value
$("#image_output_image")[0].style.display="block";
}
</script>
21 changes: 21 additions & 0 deletions tools/base64ImageEncode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<input class="form-control btn, btn-info" type="file" id="imageInput" />
<textarea class="form-control" id="image_output"></textarea>

<button class="btn btn-primary" onclick="copyToClipboard('image_output', 'Image')">
<i class="fa-solid fa-clipboard"></i>
Copy
</button>
<script>
document.getElementById('imageInput').addEventListener('change', function (event) {
var file = event.target.files[0];
if (file) {
var reader = new FileReader();

reader.onload = function (readerEvent) {
var base64String = readerEvent.target.result;
$("#image_output")[0].value=base64String;
}
reader.readAsDataURL(file);
}
});
</script>