Код:
@echo off &setlocal enabledelayedexpansion
set in=z:\sklad\
set out=c:\windows\Web\Wallpaper\
set i_view=i_view32.exe
for /f %%s in ('wmic DesktopMonitor get ScreenHeight^,ScreenWidth /value ^|find "="') do set "%%s"
for /f "delims=" %%f in ('dir /b/a-d/s %in%\*.jpg') do (
title "%%f"
%i_view% "%%f" /info=%temp%\info.tmp
for /f "tokens=4,6" %%x in ('type %temp%\info.tmp ^|find "Image dimensions"') do (
set /a newx=%%x*%ScreenHeight%/%%y &set /a newy=%%y*%ScreenWidth%/%%x
if "!newy!" GEQ "%ScreenHeight%" %i_view% "%%f" /resize_long=%ScreenWidth% /aspectratio /resample /convert=temp.bmp
if "!newx!" GEQ "%ScreenWidth%" %i_view% "%%f" /resize_short=%ScreenHeight% /aspectratio /resample /convert=temp.bmp
%i_view% %in%\temp.bmp /info=%temp%\info.tmp
for /f "tokens=4,6" %%x in ('type %temp%\info.tmp ^|find "Image dimensions"') do (
if "%%y" GTR "%ScreenHeight%" (
set /a starty=^(%%y-%ScreenHeight%^)/2
%i_view% %in%\temp.bmp /crop=^(0,!starty!,%ScreenWidth%,%ScreenHeight%^) /jpgq=90 /convert=%out%\%%~nf.jpg
)
if "%%x" GEQ "%ScreenWidth%" (
set /a startx=^(%%x-%ScreenWidth%^)/2
%i_view% %in%\temp.bmp /crop=^(!startx!,0,%ScreenWidth%,%ScreenHeight%^) /jpgq=90 /convert=%out%\%%~nf.jpg
)
)
)
)
del /q %temp%\info.tmp %in%\temp.bmp