Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
save image problem
  • hi
    i have problem when save image.
    original image info : 2048*1365 - 175.5 kB - 72dpi
    output  image info : 2048*1365 - 1.0 MB - 96dpi (why?)
    my code :
    $savepath    = 'assets'.DS.'img'.DS.'new';
    $output_name = 'dsa';
    $config      = [
                "path"          => DOCROOT,
                $savepath,
                "randomize"     => true,
                "ext_whitelist" => ["jpg", "jpeg", "png"],
                'quality'       => 50,
    ];
    if (\Input::file('asd'))
    {
                if (!is_dir(DOCROOT.$savepath))
                {
                    \File::create_dir(DOCROOT, $savepath, 0755);
                }
                \Upload::process($config);
                if (\Upload::is_valid())
                {
                    \Upload::save(DOCROOT.$savepath);
                    $image_upload = \Upload::get_files();


                    $image_name = $output_name ?: $image_upload[0]["saved_as"];
                    \Image::load(DOCROOT.$savepath.DS.$image_upload[0]["saved_as"])
                            ->save(DOCROOT.$savepath.DS.$output_name.'.'.$image_upload[0]["extension"]);


                    echo str_replace("\\", "/", $savepath.DS.$image_name.'.'.$image_upload[0]["extension"]);
                }
                else
                {
                    echo 'not valid';
                }
    }
    else
    {
                echo 'no image';
    }
  • pompexpompex
    Accepted Answer
    Maybe because you change the image quality? 
    'quality'       => 50,
  • hi
    no i set image quality to 0 and 1 but no change in output image size (1mb)
  • Not sure why you use the Image class and it's transformation properties to simply save an uploaded image? The upload class does that very well without any help?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion