Resizing only pictures bigger then 250KB raw size and ONLY shrin - RealWorld forums

Log-in or register.

Resizing only pictures bigger then 250KB raw size and ONLY shrin

Sparksman
on February 16th 2011

Hello everyone

I've a server full of client pictures! (stored in their relevant home dir)
the pictures contains raw file sizes from 1-5MB, depending of their resolution (f.e. 2560x1920 till 320x256 aso.)

I got the job to ONLY shrink their raw file size (because the server starts to explode), but keep the rest of it UNTOUCHED (ratio, resolution, pixels, chroma subsampling, creation time aso.)

I'd also like to skip pics with an already raw size of <= 250KB, because after some tests with picture resizer I noticed the pic quality after processing was sometime significant more worse by almost same file size, hence my wish to skip those small files!

I got in my tests very good results with "PhotoResize.exe -e -q60 -x11 -d100 "-c<ROOT>\Resized Photos\<NAME>.jpg" "C:\Temp\PhotoResize\ORGPIC\2010-09-08"! But this will change ANY pic(s) thrown to picture resizer...

So, the only thing I can't get to work is to skip small pic files BEFORE processing! -kX sounded promisingly, but in the end it is only the file size for OUTPUT AFTER PROCESSING... not really what I want!

So is there anyone who could help me with my small problem?

Many thanks in advance for any good suggestions & hints!

Regards

Sparksman

Vlasta
on February 16th 2011

I am afraid Picture Resizer cannot do what you need on its own, you would need to use some kind of scripting environment to filter the files.

BTW it would be safer to use -p100 instead of -d100 as it would change the pixel size of image that have different resolution than 100 DPI.

Sparksman
on February 17th 2011

Hello Vlasta!

Thanks for your fast reply!

Well, I thought so, but no sweat, I'll consider my needs within the batch script itself!

However, would be a nice function/option for the next release of Picture Resizer... ^^

Regards

Sparksman

Sparksman
on March 1st 2011

to anyone who is interested, here is my working concept...

I primary get a list of to processing pics with the following robocopy command (robocopy is a part of windows cmd line tools since xp sp3 >> win7):

robocopy "%FROM%" "%TO%" "%WHAT%" /MIN:%SIZE% /XD "%EXCLUDE%" /L /E /R:2 /W:2 /LOG:"%LOG%" /FP /NDL /NP /NJH /NJS /NS /NC

(parameter %TO% is only needed for proper robocopy working, and has no meaning for gaining the needed data, hence can contain any VALID path you like; %WHAT% is in my case "*.JPG" since we wanna use photoresizer who can only handle jpg's so far...)

after the log file (%LOG%) is written, it contains with above used parameters only the full path\filename.ext of files bigger then %SIZE% (in Bytes!!!), without any usual additional robocopy log information except error messages = nice way getting adapted file logs; See robocopy built in help "robocopy /?"

to start the photoresizer process I simply deliver the content of the logfile to photoresizer.exe with this qad script...

-----

FOR /F "usebackq delims=" %%a in ("%LOG%") do set TEST=%%a& call :PRINT

goto :EOF

:PRINT

set CHECK=!TEST:~6,11!

if !CHECK! neq %SERVER% (
        echo *INVALID LINE* -!TEST:~6!-
) else (
REM     echo -!TEST:~6!-
        PhotoResize.exe -e -q60 -x11 -p100 -i "-o<SRCPATH><EN>" "!TEST:~6!">>"%HOME%\PHORES.TXT"
)

goto :EOF

-----

I'll describe the script only very quickly...

- FOR /F loop parameter "usebackq" is needed to parse paths/filenames with " " (Space) within correctly! without you'll get an error or you can only use paths/filenames without any " " inside!

- 2 times of "goto :EOF" are needed to run and close the FOR /F loop and calling sub routine properly! For more help see "for /?" "goto /?" and "call /?"

- in my case I'll check the logfile for unwanted additional robocopy error entries... I simply check the first 11 signs of the whole path line with an predefined string! if it doesn't match it'll be likely a robocopy error entry (considered my used robocopy parameters for a simple log creation only! YES, errors are STILL written even with above parameters!)

- to start the sign check with the predefined string at the current log line we HAVE to start at token position 6, because robocopy default formats the log entry lines with a bunch of tabs and white spaces BEFORE writing the path! (you may have to adjust the token position digit to your needs; I'm working with an german windows environment) of course if you don't wanna/have to check the log entries, you can avoid the "if else" construct and just deliver the path directly to photoresizer.exe with an simply FOR /F loop without calling a sub routine...

- the used photoresizer.exe parameters are tested properly by me and ONLY shrink the whole filesize without touching the rest of the pic (frame size, dpi, ratio, etc.)

- use the script suggestion like you wish... but don't blame me if you change/destroy your valuable pics without testing it before!

regards

Sparksman

Sparksman
on March 1st 2011

meh... weird automatic post format behavior... but I'm sure you can read the post properly and you'll get the point...

Vlasta
on March 1st 2011

Thanks for sharing, I am sure there are people, who will appreciate it! (I have fixed your formatting.)

Sparksman
on March 1st 2011

yeah... just saw it! thanks! ^^

Page views: 10582       Posts: 7      
Select background
Vista & Win 7 icons
What about ICL files?