Resizing image from existing file

I have a image in document root of website in following location.

http://localhost/1502978213img_1304.jpg

 

I need to get this image and need to resize using following function,

$input_name = 'http://localhost/1502978213img_1304.jpg';
get_resized_image_from_existing_file($input_name, $size_info['w'], $size_info['h'], $size_info['square'], $size_info['upscale']);

but the above method is not working, how can I achieve it ?

  • First parameter of get_resized_image_from_existing_file() is the filename (including path) and not an url. What's the point even with trying to resize an image that's in document root? Seems much easier to resize the image locally instead. And if you are trying to implement some code for resozing uploaded images these image files won't end in the document root anyway - if you can even save them there in the first place as the document root should have write permissions for the webserver for sure!

  • @iionly Thanks. Yes I am using the full path as follows

    $file->->getLargeHeaderOnFilestore();

    which displays the path some thing like C:/wamp64/www/data/2015/02/18/44/profile/img_133.jpg , but the file is not resizing. I just want to take the image file from data folder and need to resize it and store it. could you help me ?

  • Can anyone help on this. I have the following function, where $input_name refers an existing file in data folder as follows.

     

    $input_name = $file->getFilenameOnFilestore();
    
    get_resized_image_from_existing_file($input_name, $size_info['w'], $size_info['h'], $size_info['square'], $size_info['upscale']);

     

     

    But the file is not resizing.

     

     

  • Are you sure that you have the existing file on the file store?

    How you check it?

    Perhaps, this tutorial could help you with it.

  • @RVR I had resolved it myself by removing  foreach loop in script, anyway thanks for looking into this. :)