Results 1 to 3 of 3

Thread: Command line to get image dimensions

  1. #1
    IV Newbie Swifty's Avatar
    Join Date
    Feb 2010
    Location
    Here
    Posts
    2
    Version
    IrfanView 4.25
    OS
    32-bit Win XP Pro SP3
    CPU Cores
    2

    Question 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. #2
    Power User Foxy's Avatar
    Join Date
    Aug 2007
    Posts
    819
    Version
    IrfanView 4.25
    OS
    32-bit Win XP Pro SP3

    Default

    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 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)

  3. #3
    IV Newbie Swifty's Avatar
    Join Date
    Feb 2010
    Location
    Here
    Posts
    2
    Version
    IrfanView 4.25
    OS
    32-bit Win XP Pro SP3
    CPU Cores
    2

    Default

    Brilliant! Thank you!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •