I am looking to create a client site solution using HTML, CSS and Javascript.
My requirements are:
I have the image URL. Now, I need help in creating a solution in javascript that gets the image from URL, resize it to 600px width (while keeping the aspect ratio) and downloads the image in the browser.
Can I do that? Now sure where to start with the code and I have looked everywhere but there is no solution that actually resize the image width and gives me the output.
This is what I have so far but it is not doing what I need:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div class="imgContainer" style="width:600px; overflow:hidden; background-color: black">
    <img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" id="imgCat">
</div>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.min.js"></script>
<script>
    $(window).load(function() {
        var heightRate =$("#imgCat").height() / $("#imgCat").parent(".imgContainer").height();
        var widthRate = $("#imgCat").width() / $("#imgCat").parent(".imgContainer").width();
        if (window.console) {
            console.log($("#imgCat").height());
            console.log(heightRate);
            console.log(widthRate);
            console.log(heightRate > widthRate);
        }
        if (heightRate <= widthRate) {
            $("#imgCat").height($("#imgCat").parent(".imgContainer").height());
        } else {
            $("#imgCat").width($("#imgCat").parent(".imgContainer").width());
        }
    });
</script>
</body>
</html>
