Announcement

Collapse
No announcement yet.

Get image dimensions from command line

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

    Get image dimensions from command line

    I'm looking for an easy way to get tif\jpg dimensions from a command line. You'd kinda think that if you can get it from Windows you could get it from a command prompt, but anyways...

    I'm working with irfanview, and I'm trying to figure out a way to return dimensions to a text file. I found the /info command, and I can write the data to a textfile. Now I'm trying to find out if there is a way to

    A.) Do all of the images in all of the subdirectories of a selected directory. (IE dir /s)
    B.) Get JUST the dimensions, not all the other stuff.

    Any help is greatly appreciated...it amazes me that I've been surfing the net for a half hour, and not found a good command line utility for getting image dimensions...

    #2
    You can find a complete list of the command options plus examples here :


    A) I don't think subdirs could be called too in one line. Maybe this can be solved by writing a batch-file.
    A tutorial of this can be found here :


    B) But I guess you also want the filename according to it. So far, i'm afraid that you have to edit that txt-file afterwards.
    But with a proper ascii-editor you could clean up the lines quite smoothly, with a find-replace tool or with RegEx functions.
    0.6180339887
    Rest In Peace, Sam!

    Comment


      #3
      Thank you for the help...I think I'm on the right track. I do have one more question, is there any way to get irfanview to append to a text file instead of overwriting it?

      Comment


        #4
        I'm not sure if i understand your question correctly.
        IV can open txt files, but of course only can save them as a bitmap.
        0.6180339887
        Rest In Peace, Sam!

        Comment


          #5
          Install ImageMagick (www.imagemagick.org). You get several utilities - "identify" is one of them.
          Usage example:
          >identify -format "%f %w %h" *.tif
          ev01_40.tif 8731 8732
          ev01_41.tif 8674 8648
          ev01_42.tif 8730 8722
          >

          Comment


            #6
            Here’s your help; use a batch script like the following (you must configure – see ”Configuration” block – this script before running it):
            @echo off
            cls
            setlocal

            :: --- Configuration --->

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

            :: Dimension file path/name
            set dims=C:\My Pictures\dimensions.txt

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

            :: File extensions
            set filext=*.jpg *.tif

            :: <--- Configuration ---

            for /r %1 %%a in (%filext%) do call :EXTRACT "%%a"
            goto :END

            :EXTRACT
            "%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 >> "%dims%"
            echo Width: %width% Pixel >> "%dims%"
            echo Height: %height% Pixel >> "%dims%"
            echo. >> "%dims%"

            goto :EOF

            :END
            if exist %info% del %info%

            endlocal



            Save this code, for example, as ”dim.cmd” and run it as:
            "C:\My Scripts\dim.cmd" "C:\My Pictures"
            Last edited by Foxy; 04.08.2010, 01:34 AM.
            »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

            Working...
            X