Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

client side image resize?

  • 30-03-2006 9:54am
    #1
    Registered Users, Registered Users 2 Posts: 849 ✭✭✭


    The age old problem of large images and low bandwidth has come up again ..
    I have tried to get the person to resize images manually however it seems like alot of extra work to them.

    Im looking for a client side way of resizing images in a browser before uploading to a server .. anyone got any ideas?

    I've seen a few java solutions that might do the job but im looking for something open source or free.


Comments

  • Closed Accounts Posts: 975 ✭✭✭squibs


    I asked this about a month ago - didn't get much of a response. I'm going to use max file size to prevent abuse and then I will resize on the server.


  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    Cr8or wrote:
    I have tried to get the person to resize images manually however it seems like alot of extra work to them.
    On Windows, resizing with Microsoft Paint is really easy.
    • Launch Microsoft Paint
    • Open image
    • Ctrl-W (Image, Stretch/Skew) to resize. Enter same percentage (<100%) in each box.
    • If new size is good then save, else Ctrl-Z (Edit/Undo) and choose a different percentage.


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    What language are you using PHP (look into GD library) or asp (check ASP Upload)


  • Registered Users, Registered Users 2 Posts: 1,452 ✭✭✭tomED


    You're much better off doing it server side and once off rather than on the fly.

    PHP has some great functions, but as per louie's post, you will beed GDlib. Most hosting companies will have this installed.

    Here's a sample of code we use on a site:

    [PHP]

    $uploaddir = '/yourpathtoimages/';

    $t = time();
    $uploadfil1 = $uploaddir .$t.str_replace(" ", "-",$_FILES);
    $main_image = $t.str_replace(" ", "-",$_FILES);

    $uploadfile = mysql_escape_string($uploadfil1);
    if (copy($_FILES, $uploadfile))
    {
    $msg= "File is valid, and was successfully uploaded. Record inserted.\n ";
    }
    else
    {
    $msg= "Possible file upload attack!\n";
    print_r($_FILES);
    }
    $typ1 = str_replace(" ", "-",$_FILES);



    $small_image = "small-".$t.str_replace(" ", "-",$_FILES) ;
    $image_attr = getimagesize($uploadfile);

    //echo $uploadfile . " ";

    $size = 75;
    $percentage = ($size / $image_attr[0]);

    // Get the new image size
    $width = round($image_attr[0] * $percentage);
    $height = round($image_attr[1] * $percentage);

    exec("/usr/bin/convert " . $uploadfile." -resize ".$width."x".$height." ".$uploaddir . $small_image);
    [/PHP]


  • Registered Users, Registered Users 2 Posts: 849 ✭✭✭Cr8or


    problem is he is uploading high res images and his on a slow connection so he would have to wait for ages for them to upload.

    http://upload.thinfile.com/image/ seems to do the job it changes the size then uploads.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,647 ✭✭✭impr0v


    Microsoft have a freely available utility that plugs into windows and allows you to resize images from within windows explorer, it's called the Image Resizer Powertoy and can be downloaded via this link: http://download.microsoft.com/download/whistler/Install/2/WXP/EN-US/ImageResizerPowertoySetup.exe


Advertisement