Conversation
There was a problem hiding this comment.
give an option to download the image after converting to jpg
There was a problem hiding this comment.
Requested changes has been made 🎉
There was a problem hiding this comment.
It throws the error -Failed to convert the image. Find out why and fix it.
There was a problem hiding this comment.
Requested changes has been made 🎉
There was a problem hiding this comment.
This code does not work. Use this format -
<title>Convert to JPG - ILuvImages</title>Convert Image to JPG Format
Expand All
@@ -41,9 +42,11 @@ <h1>Convert Image to JPG Format</h1>
<button class="option-button" onclick="location.href='resize_image.html'">Resize Image</button>
<button class="option-button" onclick="location.href='convert_to_png.html'">Convert to PNG</button>
<button class="option-button" onclick="location.href='convert_to_jpg.html'">Convert to JPG</button>
<button class="option-button" onclick="location.href='apply_filter.html'">Apply Filter</button>
<button class="option-button" onclick="location.href='compress_image.html'">Compress Image</button>
<button class="option-button" onclick="location.href='crop_image.html'">Crop Image</button>
</div>
</div>
<script>
document.getElementById('convertButton').addEventListener('click', function() {
const input = document.getElementById('imageInput');
if(input.files.length === 0) {
alert('Please select a PNG image to convert.');
return;
}
const file = input.files[0];
if(file.type !== 'image/png') {
alert('The file must be a PNG image.');
return;
}
// Assuming a function convertImageToJPG exists to handle the conversion
// This is a placeholder for actual conversion logic which would likely involve
// sending the file to a server for processing and then downloading the result
convertImageToJPG(file).then(result => {
alert('Image has been converted to JPG format.');
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = result;
downloadLink.click();
}).catch(error => {
console.error('Error converting image:', error);
alert('Failed to convert image.');
Expand All
@@ -56,8 +59,8 @@ <h1>Convert Image to JPG Format</h1>
});
});
// Placeholder for actual conversion function
async function convertImageToJPG(file) {
// Simulate a real conversion process
console.log('Converting', file.name, 'to JPG format...');
await new Promise(resolve => setTimeout(resolve, 2000)); // Simulates conversion delay
console.log(file.name, 'converted to JPG format.');
const result = 'data:image/jpeg;base64,converted_image_data'; // Replace with the actual converted image data
return Promise.resolve(result); // Simulates successful conversion
}
</script>
and make the page to convert to png
There was a problem hiding this comment.
Requested changes has been made 🎉
There was a problem hiding this comment.
It throws the error -Failed to convert the image. Find out why and fix it. This happens everytime i upload an image to it.
There was a problem hiding this comment.
Requested changes has been made 🎉
🚀 Here's the PR! #9
⚡This is an automated 🛠️ Pull Request raised by Codemonk
Issue: give an option to download the image after converting in the convert_to_jpg page