locked
Getting image width height before display (downloading from remote server) RRS feed

  • Question

  • User1570265326 posted

    i am going to make avatar option

    users will be able to use their own images


    but for security reasons i wont save pictures to my folders

    so they will be able to use image upload sites

    like images hack


    but the problem is image resize

    i want to display images like maxium 150*150

    i know that if i set one property image will be auto resized

    so if i can get the image size i can set image sizes according to the users picture image size


    or is there any way to set image size like if height bigger than 150 and height is bigger than width than set height 150

    or if width bigger than 150 and height smaller than width set width 150


    or if image width and height smaller than 150 use original sizes


    i really need help ty

    Saturday, October 17, 2009 5:05 PM

Answers

  • User78336405 posted

    Hi,

    From your description, I think you can get the Image size like this:

    <script language='JavaScript'> 
    function getImgSize(imgSrc)
    {
    var newImg = new Image();
    newImg.src = imgSrc;
    var height = newImg.height;
    var width = newImg.width;
    alert ('The image size is '+width+'*'+height);
    }
    </script>


     If there have been any misunderstanding, please let me know.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 21, 2009 11:15 PM

All replies

  • Monday, October 19, 2009 2:39 AM
  • User78336405 posted

    Hi,

    From your description, I think you can get the Image size like this:

    <script language='JavaScript'> 
    function getImgSize(imgSrc)
    {
    var newImg = new Image();
    newImg.src = imgSrc;
    var height = newImg.height;
    var width = newImg.width;
    alert ('The image size is '+width+'*'+height);
    }
    </script>


     If there have been any misunderstanding, please let me know.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 21, 2009 11:15 PM