bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

i need some correction in my code. am getting Image::Resize->new(): usage error

my $Newfile='0911'; my $copy_dir_qfn = 'avator/'; my $upload_fh = $CGI->upload("IMAGE"); my $image = Image::Resize->new($upload_fh); my $gd = $image->resize(100, 100); my ($file_extension) = $gd =~ /([^.]+)$/; my $rename = $copy_dir_qfn."$Newfile.$file_extension"; open OUTFILE,'>',$rename or die "$!"; binmode OUTFILE; while (<$upload_fh>){ print OUTFILE; } close OUTFILE;

Replies are listed 'Best First'.
Re: image resize error
by Corion (Patriarch) on Oct 19, 2018 at 06:17 UTC

    Have you compared your code to the documentation of Image::Resize? Where in the documentation do you find your usage?

    Please write down in plain English what you are doing in lines 3 and 4 of your code:

    my $upload_fh = $CGI->upload("IMAGE"); my $image = Image::Resize->new($upload_fh);

      am uploading image to be read by image resize and resize

      and no usage in documentation

      i also dont know why i get that error

        So, why do you expect things to work that way if you did not find the usage documented?

        The next step is for you to read the documentation of Image::Resize and to change your code so it fits the documentation.

        Your English description of what the two lines do is wrong - there is no line of code that is uploading an image. There is only a line that returns a filehandle of a file that was already uploaded to your server. You then use that filehandle as an argument to Image::Resize.

        A reply falls below the community's threshold of quality. You may see it by logging in.