Sign in to follow this  
Followers 0
corgano

Search google for terms based on image.

5 posts in this topic

I am trying to write a macro to auto-tag images in my library. I am looking for a way to search google images, but NOT trying to get images - I instead want to search an image and get possible words for it.

Things I've tried:

  • I've searched the forums, but almost every hit was searching a phrase to get images - I want to do the opposite.
  • I found two threads on it, One had no answer, and the other used the winhttp udf - which I can never get to work properly :/
  • I could try using IE functions, but it's messy and there's no way to do it completely in the background, which is much preferred :/

Does anyone have any suggestions? Or should I suck it up and use IE?


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

I know how much you guys love code. I found a pics,it example on the forum, and tried changing it to work for the google search-by-image url / request. This is what I got

#include <WinHTTP.au3>
#include <zlib.au3>

;~ http://pics.lt/index.php?lang=english

Global $sBoundary = '--' & _GenerateAlphaNumericRandomString ( 50 )

$sImagePath = @ScriptDir&"\0.jpg"
If Not FileExists ( $sImagePath ) Then Exit 1

$sDirectLink = _PicsItUpload ( $sImagePath )
ConsoleWrite ( 'Direct Link : ' & $sDirectLink & @Crlf )
If $sDirectLink Then ShellExecute ( $sDirectLink )

Func _PicsItUpload ( $sImagePath )
    If FileGetSize ( $sImagePath ) > 10*1024*1024 Then Return -1 ; max 10 MB
    Local $ReceivedData = Binary ( '' ), $chunk, $iExtended


    Local $hOpen = _WinHttpOpen ()
    Local $hConnect = _WinHttpConnect ( $hOpen, 'images.google.ca' )
    Local $hRequest = _WinHttpOpenRequest ( $hConnect, 'POST', '/searchbyimage/upload', 'HTTP/1.1' )
    _WinHttpAddRequestHeaders ( $hRequest, 'Referer: http://images.google.ca/' )
    _WinHttpAddRequestHeaders ( $hRequest, 'Accept-Encoding: gzip, deflate' )
    Local $sDataToSend = _PicsItSetDataToSend ( $sImagePath )
    If Not @error Then
        _WinHttpAddRequestHeaders ( $hRequest, 'Content-Length: ' & StringLen ( $sDataToSend ) )
        Local $sContentType = 'Content-Type: multipart/form-data; boundary=' & StringTrimLeft ( $sBoundary, 2 )
        _WinHttpSendRequest ( $hRequest, $sContentType, $WINHTTP_NO_REQUEST_DATA, StringLen ( $sDataToSend ) )
        _UploadProgress ( $hRequest, $sImagePath, $sDataToSend )
        If Not @error Then
            _WinHttpReceiveResponse ( $hRequest )
            If _WinHttpQueryDataAvailable ( $hRequest ) Then

                Local $sHeader = _WinHttpQueryHeaders($hRequest) ; ...get full header
                While 1
                    $chunk = _WinHttpReadData ( $hRequest, 2, 1024 )
                    If Not @extended Then ExitLoop
                    $ReceivedData &= $chunk
                WEnd
                $ReceivedData = BinaryToString ( _ZLIB_GZUncompress ( $ReceivedData ), 1 )
            EndIf
        EndIf
    EndIf
    _WinHttpCloseHandle ( $hRequest )
    _WinHttpCloseHandle ( $hConnect )
    _WinHttpCloseHandle ( $hOpen )
    If $sHeader Then
        ConsoleWrite("Recieved"&@CRLF&$sHeader&@CRLF)
;~         Local $aRet = StringRegExp ( $ReceivedData, '(?s)(?i)codedirect" value="(.*?)"', 3 )
;~         If Not @error Then Return $aRet[0]
    EndIf
EndFunc ;==> _PicsItUpload ()

Func _PicsItSetDataToSend ( $sFilePath )
    If Not FileExists ( $sFilePath ) Then Return SetError ( -1 )
    Local $hFile = FileOpen ( $sFilePath )
    If $hFile = -1 Then Return SetError ( 1, 0, 0 )
    Local $sData = FileRead ( $hFile )
    FileClose ( $hFile )
    Return $sBoundary & @CRLF & _
        'Content-Disposition: form-data; name="fileName[]"' & @CRLF & @CRLF & $sFilePath & @CRLF & $sBoundary & @CRLF & _
        'Content-Disposition: form-data; name="file[]"; filename="' & _FileGetFullNameByFullPath ( $sFilePath ) & '"' & @CRLF & _
        'Content-Type: image/jpeg' & @CRLF & @CRLF & $sData & @CRLF & $sBoundary & @CRLF & _
        'Content-Disposition: form-data; name="alt[]"' & @CRLF & @CRLF & _FileGetNameWithoutExtByFullPath ( $sFilePath ) & @CRLF & $sBoundary & @CRLF & _
        'Content-Disposition: form-data; name="submit"' & @CRLF & @CRLF & 'Upload' & @CRLF & $sBoundary
EndFunc ;==> _PicsItSetDataToSend ()

Func _UploadProgress ( $hRequest, $sPicPath, $sDataToSend )
    If Not FileExists ( $sPicPath ) Then Return SetError ( -1 )
    Local $sDatas = StringToBinary ( $sDataToSend )
    Local $iNumberOfBytesToSend = 1024
    Local $Bin, $iStart = 1, $iExtended = 0
    While 1
        $Bin = BinaryMid ( $sDatas, $iStart, $iNumberOfBytesToSend )
        If BinaryLen ( $Bin ) = 0 Then Return
        _WinHTTPWriteData ( $hRequest, $Bin, 1 )
        If Not @error Then
            $iExtended += @extended
            ConsoleWrite ( '+ $iPercent : ' & Round ( ( $iExtended  ) / ( StringLen ( $sDataToSend ) ) * 100, 2 ) & @Crlf )
            $iStart += $iNumberOfBytesToSend
        Else
            $Bin = 0
            Return SetError ( 1 )
        EndIf
    WEnd
EndFunc ;==> _UploadProgress ()

Func _FileGetNameWithoutExtByFullPath ( $sFullPath )
    Local $aPathSplit = StringSplit ( $sFullPath, '\' )
    If Not @error Then Return StringLeft ( $aPathSplit[UBound($aPathSplit)-1], StringInStr ( $aPathSplit[UBound($aPathSplit)-1], '.', 0, -1 ) - 1 )
EndFunc ;==> _FileGetNameWithoutExtByFullPath ()

Func _FileGetFullNameByFullPath ( $sFullPath )
    Local $aFileName = StringSplit ( $sFullPath, '\' )
    If Not @error Then Return $aFileName[$aFileName[0]]
EndFunc ;==> _FileGetFullNameByFullPath ()

Func _GenerateAlphaNumericRandomString ( $iLen )
    Local $sString = ''
    Do
        Switch Random ( 1, 3, 1 )
            Case 1
                $sString &= Chr ( Random ( 48, 57, 1 ) )  ; 0 to 9
            Case 2
                $sString &= Chr ( Random ( 65, 90, 1 ) )  ; A to Z
            Case 3
                $sString &= Chr ( Random ( 97, 122, 1 ) ) ; a to z
        EndSwitch
    Until StringLen ( $sString ) = $iLen
    Return $sString
EndFunc ;==> _GenerateAlphaNumericRandomString ()

It appears to work. When I look at  it gives me

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Date: Mon, 07 Jul 2014 07:51:09 GMT
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
Expires: -1
Server: gws
Set-Cookie: PREF=ID=c64ec6a73aa70b5d:U=9a78a2518fc3dcb0:FF=0:TM=1404719469:LM=1404719469:S=dndXYXDxpnyGV3G1; expires=Wed, 06-Jul-2016 07:51:09 GMT; path=/; domain=.google.ca
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alternate-Protocol: 80:quic

when what I should get is

Alternate-Protocol:80:quic
Cache-Control:public, max-age=21600
Content-Length:1759
Content-Type:text/html; charset=UTF-8
Date:Mon, 07 Jul 2014 07:14:32 GMT
Expires:Mon, 07 Jul 2014 13:14:32 GMT
Location:http://images.google.ca/search?tbs=sbi:AMhZZitHkEabunchofcraphere
Server:quimby_frontend
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
X-XSS-Protection:1; mode=block 

What I need that I'm missing is the Location:http://images.google.ca/search?tbs=sbi:AMhZZitHkEabunchofcraphere, because that tells me where to go next. I'm thinking my request must not be right, but I can't tell hoe. Any ideas?

EDIT: Further investigation makes me think it's not returning the location, because the upload isnt working, because something wrong with how I formatted the request payload / content, so I'm trying to make it look exactly how chrome tells me the request looks.See next post

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I've been messing around the wth the payload data of the request, trying to get it to match what chrome shows is sent, but I hit a snag at 'Content-Type: application/octet-stream'.

What I'm supposed to be sending is this:

_9j_4AAQSkZJRgABAQEASABIAAD_2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL_2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMj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C5if7q7mByScVrSW5e2W5jSQRNkAlCASMZHPpkVBHE9xHJYGQIZiAjNwBk9z24q4TaZ59Gp7NuM1e4mjJLpF5b3U2k22qgxeY0MylhjJ_UY75Hau4Xx_oGstG0qf2fICB5Tj5VxjGCB_TtUaaPay3QMvn3VtFM0bC2X93IiZAAbOBzk4znmnXPhKy1TU4J9O0g2kjMCwSVcYGSTgkgHHqw5H1rptKUdj0qMq9Fc9NGZqfjDT7W4mtwtxLdQuUwcBQRwefT8K5LXPFV3qlsbN4YkhyD03Nwc9T0_Cor9I_wC0bgLaSTHzWxI75389eAM5rO-xyzzCNIzuPGDxinFpLUwrZjWre7N6Hf8A2UDtS_ZQf4aKK5-VHRdh9kB_hp0JSwuY53U7VPOBnjHNFFCSE27Emu3kFzYOIX3TB1lj45BU5z_OtvxlDFNDrPmIrgQ7xn12DBooqpdDNbsx4LWaO_uo7J5ITukEKwJ95htyoA7kKRiuauH1G31uCw1RDFd-ZHHNCSpJ3jq2OAeRxRRWypxfvNamHtJLRMfpDxx381ut4Y4xklHjLkYPQDoPxNXpJxFctKJpAy42BY8E5-nSiiuKt_ER9bk1WfsGrlyK8Tabi7vrYLtKqjIHfI65P8I-hP4VWiuYr2d4d6OroCF65B9fqKKKKUVqzxMTUlKTv3My7_dC-snJfaYplOPmZQGyufXH5hauw2MUnkLkuZibiQxDIx_CPmx6r-CmiiuqySOJN8zL7RhRHG64DAohLd85x07_ADflWSyedEk23YrO6xkfxBSefbgZoorFQVmZV4pq502geIprGxWxbabWMk7FXGzJyWz0ySTV5PEsU5k2ktahTlgeduO_4dqKKI15paM9LDVZewXocrr3iLSrhEWyYGXIXOwjYo6BeMAVR0yELdCUESqYzKuz5umBz_31-lFFaVYrVnhYpL2lz__Z 

but when I fileread() the image, all I get is this:

ÿØÿà

But it FileGetSize says the size is indeed 2933. How do I read the image, and what do I do to the format to get it to look like the above example?

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

Revisiting old posts, and this is still something I'm wondering how to do. Does anyone know a way to search for tags for an image (using google or something else?)


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

Well, about your fileread issue: you'll need to specify binary file reading mode when reading a file you know/expect to be binary:

#include <FileConstants.au3>

Local $hFileOpen = FileOpen("c:\temp\test.png", $FO_READ + $FO_BINARY)
Local $sFileRead = FileRead($hFileOpen)
MsgBox(0, "", "Contents of the file:" & @CRLF & $sFileRead)
FileClose($hFileOpen)

No idea about those other things. Good luck :)


Roses are FF0000, violets are 0000FF... All my base are belong to you.

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

  • Similar Content

    • Ascer
      By Ascer
      1. Description.
      oAuth 2.0 is security system implemented by Google a few years ago. You are able to connect into your Google accounts and manage documents. In this UDF i show you how to pass first authorization process., this allow you to automate most of functions using API interface. 2. Requirements.
      Google account. oAuth.au3 Download 3. Possibilities
      ;============================================================================================================ ; Date: 2018-02-10, 14:21 ; ; Description: UDF for authorize your app with oAuth 2.0 Google. ; ; Function(s): ; oAuth2GetAuthorizationCode() -> Get Code for "grant". ; oAuth2GetAccessToken() -> Get "access_token" and "refresh_token" first time. ; oAuth2RefreshAccessToken() -> Get current "access_token" using "refresh_token". ; ; Author(s): Ascer ;============================================================================================================ 4. Enable your Google API.
          4.1. Video Tutorial not mine!
       YouTube     4.2 Screenshots from authorization process (Polish language) 
      Go to https://console.developers.google.com/apis/dashboard and accept current rules.  

       
      Next create an new project  

       
      Enter name of you new project and click Create  

       
      Google will working now, please wait until finish. Next go to enable your API interface, we make if for Google  

       
      Take "Gmail" in search input and after click in found result.  

       
      Click Enable interface, Google will working now.  

       
      Create your login credentials  

       
      Select Windows Interface (combobox), User credentials (radio) and click button what is need bla bla  

       
      Type name of a new client id for oAuth 2.0 and click Create a new Client ID.  

       
      Next configure screen aplication, type some name and click Next. Google will working now.  

       
      Last step on this website is download source with your credentials in *Json format.  

       
      Now you received a file named client_id.json, it's how it look in Sublime Text:  

       
      5. Coding.
      Now we need to call a some function to get access code.  
      #include <oAuth.au3> Local $sClientId = "167204758184-vpeues0uk6b0g4jrnv0ipq5fapoig2v8.apps.googleusercontent.com" Local $sRedirectUri = "http://localhost" oAuth2GetAuthorizationCode($sClientId, $sRedirectUri)  
      Function will execute default browser for ask you to permission.  

       
      Next Google ask you to permission for access to your personal details by application Autoit   

       
      Now you can thing is something wrong but all is ok, you need to copy all after  code= . It your access code.  

       
      Let's now ask Google about our Access Token and Refresh Token  
      #include <oAuth.au3> Local $sClientId = "167204758184-vpeues0uk6b0g4jrnv0ipq5fapoig2v8.apps.googleusercontent.com" Local $sClientSecret = "cWalvFr3WxiE6cjUkdmKEPo8" Local $sAuthorizationCode = "4/AAAPXJOZ-Tz0s6mrx7JbV6nthXSfcxaszFh_aH0azVqHkSHkfiwE8uamcabn4eMbEWg1eAuUw7AU0PQ0XeWUFRo#" Local $sRedirectUri = "http://localhost" Local $aRet = oAuth2GetAccessToken($sClientId, $sClientSecret, $sAuthorizationCode, $sRedirectUri) If Ubound($aRet) <> 4 then ConsoleWrite("+++ Something wrong with reading ResponseText." & @CRLF) Exit EndIf ConsoleWrite("Successfully received data from Google." & @CRLF) ConsoleWrite("access_token: " & $aRet[0] & @CRLF) ConsoleWrite("expires_in: " & $aRet[1] & @CRLF) ConsoleWrite("refresh_token: " & $aRet[2] & @CRLF) ConsoleWrite("token_type: " & $aRet[3] & @CRLF)  
      Important! When you received error 400 and output says: Invalid grant it means that your previous generated access_code lost validity and you need to generate new calling previus code. When everything is fine you should received a 4 informations about your: access_token, expires_in, refresh_token and token_type. Access_Token time is a little short so you need to know fuction possible to refresh it (tell Google that he should generate a new Token for you)  
      #include <oAuth.au3> Local $sRefreshToken = "1/ba8JpW7TjQH3-UI1BvPaXhSf-oTQ4BmZAbBfhcKgKfY" Local $sClientId = "167204758184-vpeues0uk6b0g4jrnv0ipq5fapoig2v8.apps.googleusercontent.com" Local $sClientSecret = "cWalvFr3WxiE6cjUkdmKEPo8" Local $sRedirectUri = "http://localhost" Local $aRet = oAuth2RefreshAccessToken($sRefreshToken, $sClientId, $sClientSecret) If Ubound($aRet) <> 3 then ConsoleWrite("+++ Something wrong with reading ResponseText." & @CRLF) Exit EndIf ConsoleWrite("Successfully received data from Google." & @CRLF) ConsoleWrite("access_token: " & $aRet[0] & @CRLF) ConsoleWrite("expires_in: " & $aRet[1] & @CRLF) ConsoleWrite("token_type: " & $aRet[2] & @CRLF)  
      6. Finish words
      If you followed all this above steps im sure that you received all informations required for coding your Google API (Gmail, Dropbox, YouTube, Calender etc. See next thread: [UDF] Gmail API - Email automation with AutoIt!
    • dadalt95
      By dadalt95
      Perform a simple google search!
      The script below works fine until fill the google form!
      What I can't find is how to submit the form, tried a couple of ways and none of them worked.

       
      #include <IE.au3> $oIE = _IECreate ("www.google.com") $o_form = _IEFormGetObjByName ($oIE, "f") $o_login = _IEFormElementGetObjByName ($o_form, "q") $username = "80251369" _IEFormElementSetValue ($o_login, $username) $o_numer = _IEGetObjByName($o_form, "btnK") _IEAction ($o_numer, "click")  
      The code runs without any problem.
      I don't know how to proceed!
      Thanks in advance!
    • nacerbaaziz
      By nacerbaaziz
      Hi dears
      how are you? I hope You fine
      I have a question please
      I've created a listView
      It has several columns
      Is there any way  to search for text in an element of this list with text in all columns
      for example
      list view with 2 column
      the first is the file name and the second is the file path
      and i want to search for the item witch Containt the name and the path toGether
      I searched a lot but could not find what I was looking for
      If you do not understand the idea that I'm looking for, I can put an example
      Thanks in advance
    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix