Announcement

Collapse
No announcement yet.

Command line to get image dimensions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Command line to get image dimensions

    First post here. Hello!
    Can I use Irfanview from a script to determine the dimensions of a given image (usually JPG)? I can't see a command-line switch that looks relevant.

    I have two displays; primary landscape, secondary portrait. I'm thinking of writing a script to display images randomly, but I'd like the landscape images to go to the landscape display and the portrait images to go to the portrait display. I could do all of this with technology that I already had, except reliably determining the dimensions. If there is an algorithm for extracting it from a jpg, then I could use that. I had some code that I wrote years ago, based on having found the image dimensions inside an existing JPG file, and working out how to navigate to it, but it was unreliable (no surprises there).

    #2
    The following batch script:
    @echo off
    cls
    setlocal

    :: --- Configuration --->

    :: Temp-/Infofile path/name
    set info=%temp%\info.txt

    :: IrfanView
    set iview=C:\IrfanView\i_view32.exe

    :: <--- Configuration ---

    %iview% %1 /info=%info%

    for /f "tokens=4,6" %%a in ('type %info% ^| find.exe /i "Image dimensions"') do (set /a width=%%a) & (set /a height=%%b)

    echo File: %1
    echo Width: %width% Pixel
    echo Height: %height% Pixel
    echo.

    if exist %info% del %info%
    endlocal
    returns the dimensions (width and height) of a specified pic, if you run this script as follows:

    Syntax:
    picdim.cmd [[Drive:][Path]Filename]

    Example:
    picdim.cmd "C:\MyPictures\subfolder 01\abcd 0123.jpg"
    Attached Files
    »Und so, in eurer Verzweiflung, kommt ihr zu mir.«

    Texteditor EmEditor:
    Deutsche Sprachdatei (v7.01) für EmEditor Pro 7.02 (englisch)
    EmEditor Pro 8.06 (deutsch) | Deutsche Sprachdatei (v8) für EmEditor Pro 8.06 (englisch)
    Deutsche Sprachdatei (v9.16) für EmEditor Pro 9.17 (englisch)

    Comment


      #3
      Brilliant! Thank you!

      Comment

      Working...
      X