Sign in to follow this  
Followers 0
spiderblues

Image size

17 posts in this topic

Hi,

does anybody have an idea, how I could get the size of an image, to show the SplashImageOn with the right dimensions?

Thanks...

Peter

Share this post


Link to post
Share on other sites



open it in an editor, just about any picture editor should show you it's size. irfanview should too...


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks Holger,

I'll try it next week. Especially I need it for jpg files...

Peter

Edited by spiderblues

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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])

Share this post


Link to post
Share on other sites

So, I get this message:

Posted Image

Share this post


Link to post
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? :(

Share this post


Link to post
Share on other sites

It's 3.0.102!

I have to try it again in 10 days, because I'm on vacation...

Packing my things now!

I'll tell you what I can find out...

Peter

Share this post


Link to post
Share on other sites

FYI: I posted an example of extracting image dimensions within another thread.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Thank you for the script, but when I try it with a big image (5 MPixel digicam) it takes a loooong time fpr processing, and the result is always 320x240!!

What's wrong?

Peter

Edited by spiderblues

Share this post


Link to post
Share on other sites

Well, that was exactly what I was looking for!

Thank you very much Kot!!!

Peter

Share this post


Link to post
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
Sign in to follow this  
Followers 0