Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

mobile phone image resize algorithm and I-Pad issue?

Is there a mobile phone image resize algorithm script available that will automatically resize the phones image to a smaller size? The upload feature works just fine using File Upload on a mobile if I am using saved pictures (computer to phone). If I try to take a picture with my phone and upload it though, the file is about 2MB or so, and my phone is taking a few minutes to upload them.

Any scripts available for this?

Also, on my I-Pad when I am looking at the vanilla forums and scroll down, the text box just keeps expanding and I can never get to the bottom of the page. How can I fix this?

Comments

  • BrandonPBrandonP New
    edited March 2013

    Maybe something like

    function resizeImage($filename,$max_width,$max_height='',$newfilename="",$withSampling=true)
    {
    if($newfilename=="")
    $newfilename=$filename;
    // Get new sizes
    list($width, $height) = getimagesize($filename);

    //-- dont resize if the width of the image is smaller or equal than the new size.
    if($width<=$max_width)
        $max_width=$width;
    
    $percent = $max_width/$width;
    
    $newwidth = $width * $percent;
    if($max_height=='') {
        $newheight = $height * $percent;
    } else
        $newheight = $max_height;
    
    // Load
    $thumb = imagecreatetruecolor($newwidth, $newheight);
    $ext = strtolower(getExtension($filename));
    
    if($ext=='jpg' || $ext=='jpeg')
        $source = imagecreatefromjpeg($filename);
    if($ext=='gif')
        $source = imagecreatefromgif($filename);
    if($ext=='png')
        $source = imagecreatefrompng($filename);
    
    // Resize
    if($withSampling)
        imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    else   
        imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    
    // Output
    if($ext=='jpg' || $ext=='jpeg')
        return imagejpeg($thumb,$newfilename);
    if($ext=='gif')
        return imagegif($thumb,$newfilename);
    if($ext=='png')
        return imagepng($thumb,$newfilename);
    

    }

    Taken from http://www.weberdev.com/get_example.php3?ExampleID=4629

  • edited March 2013

    That would affect the full site as well ...not sure how that function would be used in the mobile theme.

    you can use css in the mobile theme to make the images smaller and fit.

    .Message span img {max-width:250px;height:auto;}

    2MB is very heavy and large you can get the same result using 600k also remember that the larger the image the longer it takes to load.

    text box just keeps expanding and I can never get to the bottom of the page. How can I fix this?

    make the box a specific size in the mobile theme..

    .MessageForm, .CommentForm{max-width:250px;max-height:150px;overflow:auto;}
    
    or 
    
    form#Form_Comment, form#Form_Discussion {max-width:250px;max-height:150px;overflow:auto;}
    
    or if you use cleditor
    
    .cleditorMain{ {max-width:250px;max-height:150px;overflow:auto;}
    textarea#Form_Body{max-width:250px;max-height:150px;overflow:auto;}
    
    
  • 422422 MVP
    edited March 2013

    Most smartphones tho, take huge pics. I think this is gonna be a issue, however you do it. Re rendering the images on page can be handled by php resize and classed according to the device being used.

    as for text area issue, i seem to think thats an issue always related to embed. Not 100% on that

    There was an error rendering this rich post.

  • Most smartphones tho, take huge pics.

    I know , what the hell for if it will be viewed in a small device not a 55" flat screen tv !

  • @BrandonP said:
    If I try to take a picture with my phone and upload it though, the file is about 2MB or so, and my phone is taking a few minutes to upload them.

    Perhaps I misunderstood the question, but I don't think there is anything you can do about the above. Vanilla includes a function to reside pictures automatically, but the file has to be uploaded first. If your phone has a 2 MB file to send, then the whole 2 MB have to be sent before Vanilla can process it. Once uploaded, it will be smaller and downloading it will be faster, but upload speed won't change.

  • SrggamerSrggamer ✭✭✭

    @vrijvlinder said:
    I know , what the hell for if it will be viewed in a small device not a 55" flat screen tv !

    124" for me!

  • It would be nice if it would work like facebook picture upload. Wonder how they have their compression tool setup? I know I can try to upload the same mobile picture on facebook, and it automatically compresses the file from 2MB+ to about 97KB in a matter of 20 seconds or less.

    Might be something to look into, because Mobile browsing is a very popular tool

  • here are the configurations having to do with upload and picture sizing. You can try changing these values.
    You can also try this plugin http://vanillaforums.org/addon/1042/plupload it may help do that.

    $Configuration['Garden']['Upload']['MaxFileSize']               = '64M';
    $Configuration['Garden']['Upload']['AllowedFileExtensions']     = array('txt','jpg','jpeg','gif','png','bmp','tiff','zip','gz','tar.gz','tgz','psd','ai','fla','swf','pdf','doc','xls','ppt','docx','xlsx','log','rar','7z');
    $Configuration['Garden']['Picture']['MaxHeight']                = 1000;
    $Configuration['Garden']['Picture']['MaxWidth']                 = 600;
    $Configuration['Garden']['Profile']['MaxHeight']                = 1000;
    $Configuration['Garden']['Profile']['MaxWidth']                 = 250;
    $Configuration['Garden']['Preview']['MaxHeight']                = 100;
    $Configuration['Garden']['Preview']['MaxWidth']                 = 75;
    $Configuration['Garden']['Thumbnail']['Size']                   = 50;
    
    
  • what file is the settings in ? Thanks

  • @BrandonP

    Those configuration settings would go in your /conf/config.php

    @vrijvlinder found them, assumedly, in the /conf/config-defaults.php file. Never edit the config-defaults.php file!

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.