Jump to content

Image size


Recommended Posts

For Bitmaps "bmp" I could tell you.

You could read the file with "FileRead" bitwise and then locate the following positions in the file (hex-values).

weight-pos   height-pos   colordepth

12h(L)       16h(L)       1Ch
13h(H)       17h(H)

For "jpg" I look now.

Edited by Holger
Link to comment
Share on other sites

Especially I need it for jpg files...

Hmm... If you want to go really LOW level, I could provide some instructions for jpeg images. However, most of it would probably be a little difficult to parse within AutoIt. (ie: ALL jpeg files begin with the two-byte word "FFD8")

Older JPEG images typically only have one set of dimensions saved, while digital cameras and some photo editing programs embed the thumbnail information as well (these require a little more parsing).

Most Digital cameras also embed information as far as timestamps, camera model, orientation, flash settings, etc.

Link to comment
Share on other sites

I'm using Idoswin Pro as filemanager. There you only have to move over the filename, and the tooltip shows the dimensions and other attributes.

I want to show images from digicams as a splash window in different sizes, but want to calculate the x:y ratio.

I'm a beginner with autoit, and even don't know how to use the windows api.

What I know about programming is PHP , Javascript and C from the old DOS days.

But this forum helps a lot. Thanks to you all...

Peter

Edited by spiderblues
Link to comment
Share on other sites

Now I found a way, if irfanview is installed.

Pleas tell me, wheter this is good or bad what Im doing:

$img_file = "test.jpg";
$output_file = "dim.txt"
$irfan_path = "C:\Programme\Irfanview\"
$cmd = $irfan_path & "i_view32.exe " &$img_file & " /info=" & $output_file & " /killmesoftly"
Run ($cmd, "" , @SW_HIDE)

The output file looks like this:

[test.jpg]
File name = test.jpg
Directory = 
Compression = JPG/JFIF
Resolution = 0 x 0 DPI
Image dimensions = 1536 x 2048  Pixels
Print size = 54.19 x 72.25 cm; 21.33 x 28.44 inches
Color depth = 16,7 Millions   (24 BitsPerPixel)
Number of unique colors = 88045
Disk size = 1.90  MB (1988615 Bytes)
Current memory size = 9.00  MB (9437224 Bytes)
File date/time = 05.02.2004 / 17:07:00

Peter

Link to comment
Share on other sites

IniRead() didn't work! Because of the space in thekey "Image dimensions" ?

but this is working:

$img_file = "test.jpg";
$output_file = "dim.txt"
$irfan_path = "C:\Programme\Irfanview\"
$key = "Image dimensions"
$cmd = $irfan_path & "i_view32.exe " &$img_file & " /info=" & $output_file & " /killmesoftly"
Run ($cmd, "" , @SW_HIDE)

$file = FileOpen ( $output_file, 0 )
If $file = -1 Then
   MsgBox(0, "Error", "Unable to open file.")
   Exit
Else
    While 1
    $line = FileReadLine($file)    
    If @error = -1 Then ExitLoop
    If StringInStr( $line, $key) > 0 Then ExitLoop   
    Wend
EndIf
FileClose($file)

$dim = StringSplit ( $line, "=" )
$dim[2] = StringReplace ( $dim[2], " ", "")
$dim[2] = StringReplace ( $dim[2], "pixels", "")

$xy = StringSplit ( $dim[2], "x" )
MsgBox(0, "ImageDimensions", "Width: "& $xy[1] & " Pixel - Height: "& $xy[2] & " Pixel")


exit
Link to comment
Share on other sites

Ok, based in your output (like Ini file), I maded this lines:

This work for me:

$imgDims= IniRead( "output.ini", "test.jpg", "Image dimensions", "@")
$Dims= StringSplit( $imgDims, " ")
Msgbox(0, "Image Dimensions", $imgDims & @LF & "Width: " & $Dims[1] & @LF & "Height: " & $Dims[3])
Link to comment
Share on other sites

Wrong? Strange... :ph34r:

This works fine for me...

EXAMPLE

Ok, this is "Output.ini" file.

[test.jpg]
Image dimensions = 1536 x 2048  Pixels

This is the script:

$imgDims= IniRead( "output.ini", "test.jpg", "Image dimensions", "@")
$Dims= StringSplit( $imgDims, " ")
Msgbox(0, "Image Dimensions", $imgDims & @LF & "Width: " & $Dims[1] & @LF & "Height: " & $Dims[3])

What Autoit version you use? :(

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...