Hi!,
I use FileRequest() function to select one or more image files from a directory.. Then I need to know the width and the height of every image (they will have the same width and height but I don't know the size) as I need to create one brush and copy them one side by side.. I looked deeply in the doc but I didn't find any Get Function about width and height or pixel information..
Any help is appreciated
How to read width and height parameters from an image?
- NubeCheCorre
- Posts: 77
- Joined: Mon Mar 19, 2012 1:24 am
- Contact:
Re: How to read width and height parameters from an image?
The table returned by IsPicture() should do what you want.
- NubeCheCorre
- Posts: 77
- Joined: Mon Mar 19, 2012 1:24 am
- Contact:
Re: How to read width and height parameters from an image?
Thank You!! I totally missed that function! thanks!
- NubeCheCorre
- Posts: 77
- Joined: Mon Mar 19, 2012 1:24 am
- Contact:
Re: How to read width and height parameters from an image?
I tried but I still have some problem... it seems that the table is empty, very strange.. here the code I wrote to test the function:
That's the error that Hollywood report to me:
Code: Select all
@VERSION 5,0
@APPTITLE "Join Files"
@APPVERSION "$VER: Hollywood 5.0 (12-March-12)"
@DISPLAY {Title = "Join Files"}
@SCREEN {Mode = "ask", Width = 640, Height = 480}
pattern$ = "jpg|jpeg|bmp|tif|gif|png"
title$ = "Choose files"
tempfile$ = "temp.png"
f$ = FileRequest(title$,pattern$,#REQ_MULTISELECT)
NPrint("Path:", PathPart(f$[0]))
NPrint("Files selected:", ListItems(f$) - 1)
While f$[c] <> ""
NPrint(FilePart(f$[c]))
c = c + 1
Wend
d = 1 ; id brush counter
While f$[e] <> ""
LoadBrush(d,f$[e])
ret_val, table$ = IsPicture(f$[e])
If ret_val = True
NPrint("The file is an image? :", ret_val)
NPrint("Width:", table$[e])
NPrint("Height:", table$[e])
NPrint("Alpha:", table$[e])
NPrint("Vector:", table$[e])
Else
NPrint("The file is not an image...")
EndIf
d = d + 1 ;counter
e = e + 1 ;counter
Wend
WaitLeftMouse()
End()
Error in line 32 (main_util.hws): Table field 0 was not initialized!
Re: How to read width and height parameters from an image?
Hi
Try this
Try this
Code: Select all
@VERSION 5,0
@APPTITLE "Join Files"
@APPVERSION "$VER: Hollywood 5.0 (12-March-12)"
@DISPLAY {Title = "Join Files"}
@SCREEN {Mode = "ask", Width = 640, Height = 480}
pattern$ = "jpg|jpeg|bmp|tif|gif|png"
title$ = "Choose files"
tempfile$ = "temp.png"
f$ = FileRequest(title$,pattern$,#REQ_MULTISELECT)
NPrint("Path:", PathPart(f$[0]))
NPrint("Files selected:", ListItems(f$) - 1)
While f$[c] <> ""
NPrint(FilePart(f$[c]))
c = c + 1
Wend
d = 1 ; id brush counter
While f$[e] <> ""
LoadBrush(d,f$[e])
ret_val, table = IsPicture(f$[e])
If ret_val = True
NPrint("The file is an image? :", ret_val)
NPrint("Width:", table.Width)
NPrint("Height:", table.Height)
NPrint("Alpha:", table.Alpha)
NPrint("Vector:", table.Vector)
Else
NPrint("The file is not an image...")
EndIf
d = d + 1 ;counter
e = e + 1 ;counter
Wend
WaitLeftMouse()
End()
- NubeCheCorre
- Posts: 77
- Joined: Mon Mar 19, 2012 1:24 am
- Contact:
Re: How to read width and height parameters from an image?
It works, thank you!, so is it better to use this kind of syntax (table.Value) instead of table[]?
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: How to read width and height parameters from an image?
It's not a matter of syntax, your code was just plain wrong
- NubeCheCorre
- Posts: 77
- Joined: Mon Mar 19, 2012 1:24 am
- Contact:
Re: How to read width and height parameters from an image?
ok, I thought that being "table" a table, I could access to its element using a index, instead i have to use the string as index