recrusiv scale of jpg images
Hy!
I plan a jpeg archive for our complany. Unfortunatelly some people think they have to save there pictures with 5.1 mil. pixels so my database keeps growing. Now my question: I can use: for f in *.jpg ; do djpeg $f | pnmscale -xysize 1024 768 | cjpeg -qual 75 >1024-$f ; done to resale the jpegs to 1024x768 but as the users are able to create there own subfolders I would like to uses the string above recrusivly. Who can i do that ? |
Go to top directory
find . -type f -name "*.jpg" -print | while read x; do djpeg $x | pnmscale -xysize 1024 768 | cjpeg -qual 75 >1024-$x ; done |
Ok, but
-bash: 1024-./public/img_2684_2.jpg: Datei oder Verzeichnis nicht gefunden seems to me that $x could not be uses as it does not only store the filename but the whole path. trying to figer that out..... Should be something with awk -F/ {'print$2'} Thanks! |
try this command. please test it first.
Code:
OLDIFS=$IFS; IFS=$'\n' |
same mistake
./test.scr: line 4: ./1024-./public/img_2684.jpg: Datei oder Verzeichnis nicht gefunden the './1024' is at the wrong place. Two strings have to be used as 1.) I need the whole path as the source 2.) as target i need the folder then i would like to insert 1024 and then comes the old filename.... lets see.... |
sorry my mistake. used dirname instead.
Code:
OLDIFS=$IFS; IFS=$'\n' |
got it working....
Ok, its not so beautiful but IT WORKS find . -type f -name "*.jpg" -print | grep -v 1024_768_ | while read x; do echo ALT:$x pfad=`dirname $x` dateiname=`basename $x` echo NEU:$pfad/1024_768_$dateiname djpeg $x | pnmscale -xysize 1024 768 | cjpeg -qual 75 >$pfad/1024_768_$dateiname chown wwwrun $pfad/1024_768_$dateiname chmod 600 $pfad/1024_768_$dateiname mv $x /tempbilder/ done |
All times are GMT -5. The time now is 05:00 PM. |