Skip to content

Resolved button#10

Open
testbot-codemonk[bot] wants to merge 5 commits intomainfrom
button-9
Open

Resolved button#10
testbot-codemonk[bot] wants to merge 5 commits intomainfrom
button-9

Conversation

@testbot-codemonk
Copy link
Contributor

🚀 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

@testbot-codemonk testbot-codemonk bot mentioned this pull request Apr 22, 2024
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

give an option to download the image after converting to jpg

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes has been made 🎉

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It throws the error -Failed to convert the image. Find out why and fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes has been made 🎉

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code does not work. Use this format -

<title>Convert to JPG - ILuvImages</title>

Convert Image to JPG Format

Convert to JPG
    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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes has been made 🎉

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It throws the error -Failed to convert the image. Find out why and fix it. This happens everytime i upload an image to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes has been made 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant