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

On our our server we were using NETPGM to resize images. Unfortunately, this isn't working anymore and now I am looking for a way to resize images when they are uploaded. Any help or suggestions would be greatly appreciated. Here is the current code:
$ENV{PATH} .= ":/home/antiques/public_html/netpbm"; $pnmscale = "/home/antiques/public_html/netpbm/pnmscale"; $giftopnm = "/home/antiques/public_html/netpbm/giftopnm"; $ppmtogif = "/home/antiques/public_html/netpbm/ppmtogif"; if ($filetype eq 'jpg') { ## THIS WILL RESIZE DISPLAY TO A THUMBNAIL my @fileparts = split(/\./, $Filename); my $outfile = $fileparts[0] . "-T." . $fileparts[1]; #IMAG +E FACTOR: -ysize $thumbnail_height -xsize $thumbnail_width #cjpeg -qu +altiy 5-95 optional quality ###### NETPBM THUMB CALL ##### system("djpeg $SAVE_DIRECTORY\/$Filename | $pnmscale -xsi +ze $thumbnail_width | cjpeg -quality 95 > $SAVE_DIRECTORY\/$item_id\ +_$outfile"); ###### IMAGEMAGIK THUMB CALL ##### #system("convert -sample x75 $SAVE_DIRECTORY\/$Filename $S +AVE_DIRECTORY\/$item_id\_$outfile"); ## THIS WILL RESIZE TO A DISPLAY IMAGE my @fileparts2 = split(/\./, $Filename); my $outfile2 = $fileparts2[0] . "-L." . $fileparts2[1]; #I +MAGE FACTOR: -ysize $thumbnail_height -xsize $thumbnail_width ###### NETPBM DISPLAY CALL ##### system("djpeg $SAVE_DIRECTORY\/$Filename | $pnmscale -xsiz +e $display_width | cjpeg > $SAVE_DIRECTORY\/$item_id\_$outfile2"); ###### IMAGEMAGIK DISPLAY CALL ##### #system("convert -sample x240 $SAVE_DIRECTORY\/$Filename $ +SAVE_DIRECTORY\/$item_id\_$outfile2"); {system("mv $SAVE_DIRECTORY\/$item_id\_$outfile2 $SAVE_DIR +ECTORY\/$item_id\_$Filename");} {system("rm $SAVE_DIRECTORY\/$Filename");} }

Replies are listed 'Best First'.
Re: Image Resizing Help
by roboticus (Chancellor) on Mar 27, 2019 at 01:53 UTC

    koacamper1:

    It doesn't sound like a perl problem. I'd suggest running it by hand to see if the command is being created properly. You may also have to check the permissions, path, etc.

    You could modify the script to change "system" to "print" and then you could see exactly what command line it's trying to run, then you can try it by hand and see what is or isn't happening.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: Image Resizing Help
by Anonymous Monk on Mar 27, 2019 at 05:05 UTC