Jump to content
BLNJ000

How to grab the file properties of an online (image) file.

Recommended Posts

Hello to All. 

I'm trying to write a simple script that had a link of an image file (jpeg, gif, bmp etc) tell me some information [without having to download the file itself]

The info should be :

- urls file [my input]

- Width

- Height

- size

 

so I looked in the guide and in the examples what could help me, but I have some problems ...

 

I had thought of such a thing (not working):

#include <IE.au3> ; _IEBodyReadHTML ( ByRef $oObject ) ; X Internet Explore Browser
#include <MsgBoxConstants.au3>
#include <ColorConstantS.au3>;
#include <GUIConstantsEx.au3>;
#include <GuiEdit.au3>
#Include <Constants.au3>
#include <InetConstants.au3>
#include <Inet.au3>



InfoFileUrl()
Func InfoFileUrl ()

Local $sURL = "https://www.lastampa.it/image/contentid/policy:1.38524329:1582812892/puppy-looks-like-cat-dog-hybrid-14-5e53858271f0f__700.jpg" ;random test image taken on the web

Local $LinkOb = $sURL
Local $iWidth = _IEPropertyGet($LinkOb, "width")
Local $iHeight = _IEPropertyGet($LinkOb, "height")

;;------InetGetSize ( "URL" [, options = 0] )

local $size = InetGetSize ( $LinkOb , 0 ) ; https://www.autoitscript.com/autoit3/docs/functions/InetGetSize.htm
;; ------- FileGetSize ( "filename" ) ; https://www.autoitscript.com/autoit3/docs/functions/FileGetSize.htm
;only for files already on h.d, not for things online ?
;Local $size = FileGetSize ( $LinkOb )

ConsoleWrite ("Url File = " & $LinkOb & @CRLF & "Width = " & $iWidth & @CRLF & "Height = " & $iHeight & @CRLF & "Size File = " & $size )

EndFunc   ;==>InfoFileUrl
Exit

 

From other help posts on the forum I realized that the various _IE * etc * functions work on the Internet Explorer browser ... and I obviously ... use Chrome.    [ and maybe that's why I had this error message

<IE.au3 T3.0-2 Error from function _IEPropertyGet, $_IESTATUS_InvalidDataType> , or I have done something else wrong ?]

 

 

another user suggested the use of  inet*()

 

also, if you are only interested on the HTML source of a web page, you can simply use commands like InetGet(), InetRead(), _INetGetSource(). Such commands doesn't relies on any browser and can get the html listing directly from the web server.

 

I was interested in this solution because in the html code <img stile="......"> there should be Width & Height...

... I made some attempts but with no results.

 

Assuming that the starting idea is feasible, could someone please tell me what / how to correct ?

 


 

Share this post


Link to post
Share on other sites

Maybe this ?

#include <IE.au3>

Local $sURL = "https://www.lastampa.it/image/contentid/policy:1.38524329:1582812892/puppy-looks-like-cat-dog-hybrid-14-5e53858271f0f__700.jpg"
Local $oIE = _IECreate ($sURL)

$cImg = _IETagNameGetCollection ($oIE, "img")
For $oImg in $cImg
  ConsoleWrite ($oImg.width & "/" & $oImg.height & @CRLF)
Next

 

Share this post


Link to post
Share on other sites

 

Thanks for the reply, I had not considered  <_IECreate >,  now I have set it as hidden.

I did some tests starting from your example and I still have some problems , 

 

#include <IE.au3>

;Local $sURL = "https://www.lastampa.it/image/contentid/policy:1.38524329:1582812892/puppy-looks-like-cat-dog-hybrid-14-5e53858271f0f__700.jpg";ok
;Local $sURL = "https://wdtqhni.bfhcyshosymc.hath.network/h/11395e61c41b4b59f6fff9dcd19701251adea614-44268-1280-1807-jpg/keystamp=1584999000-e70b55b7d9;fileindex=58597854;xres=1280/003.jpg"; no (1280x1807)
;Local $sURL = "https://www.ilpost.it/wp-content/uploads/2019/05/gatto-attento.gif"; OK
;Local $sURL = "https://mangadex.org/data/d7d595b12c597e93846d1975cf312afd/u6.png"; no (1000x4340)
Local $sURL = "https://mangadex.org/chapter/832015/6";no
;Local $sURL = " "


Local $oIE = _IECreate ($sURL, 0,0 ,1, 0)
$cImg = _IETagNameGetCollection ($oIE,"img")
For $oImg in $cImg
  ;ConsoleWrite ($oImg.width & "/" & $oImg.height & @CRLF)
  ConsoleWrite ("Url File = " & $sURL & @CRLF & "width = " & $oImg.width & @CRLF & "height = " & $oImg.height );

;Next

_IEQuit($oIE);Close the browser and remove the object reference to it

 

If I try to use some images, an window "view download" opens  (I think it' IE , never seen before ... as said, I haven't used IE for years) in which it tells me whether to open or save the file ( and the scrip end here ).

[ img of test =  h**ps://mangadex.org/data/d7d595b12c597e93846d1975cf312afd/u6.png ]

I also saw that with the presence of _IECreate now  <_IEPropertyGet>   seems to work , but

 

 

whit the image of previus test  the window " view download" open again ...

If i try to read the initial page of the image the retur is this

 Url File =

https://mangadex.org/chapter/832015/6
larghezza = 943
altezza = 647

but the real size of the immage  are 1000x4340 ;  ( so dont' work regularly)

Do I have to add something or is there any other approach I could follow? (for the size speech there are no viable roads?) 

 

 

 

 

 

 

 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...