Jump to content
UBot Underground

Can I scrape Image properties?


Recommended Posts

Hi Folks

 

Is it possible in ubot to scrape image properties? 

 

I need to get Height and Width of approx 7000 images and then filter them down to anything less than 500 x 500 pixels

 

In firebug or chrome I can easily see the image size but I can't seem to get the uBot browser to find the image properties.

 

An example image here http://www.selby.com.au/media/catalog/product/u/h/uhf088.jpg

Link to post
Share on other sites
Hi.
 
That's not possible out of the box. But there are command line tools available who are able to deliver the pixel information's.
 
There is a commandline tool called "identify.exe"
 
So you can download the image, run a short shell script to get the pixel informations. 
 
Here is a short example:
set(#url"http://www.selby.com.au/media/catalog/product/u/h/uhf088.jpg""Global")
create folder("{$special folder("Application")}\\tmp""")
plugin command("HTTP post.dll""http file download"#url"{$special folder("Application")}\\tmp\\{$plugin function("File Management.dll""$file name"#url)}""")
set(#result$plugin function("Advanced Shell.dll""$shell batch hidden""\"C:\\Program Files\\ImageMagick-6.8.8-Q16\\identify.exe\" \"{$special folder("Application")}\\tmp\\{$plugin function("File Management.dll""$file name"#url)}\""), "Global")
set(#result2$find regular expression(#result"[0-9]+x[0-9]+\\s"), "Global")
 
 
I'm using a couple of plugins in my example, but you can do that with build in commands as well. 
 
Maybe that gives you some ideas.
 
Cheers
Dan
Link to post
Share on other sites

Hi,

 

Javascript code to get image width and height:

set(#imgurl, "http://www.selby.com.au/media/catalog/product/u/h/uhf088.jpg", "Global")
loop(2) {
    set(#imginfo, $eval("
var imgHeight
  var imgWidth

  function findHHandWW() \{
    imgHeight = this.height;imgWidth = this.width;return true
  \}

  function showImage(imgPath) \{
    var myImage = new Image()
    myImage.name = imgPath
    myImage.onload = findHHandWW
    myImage.src = imgPath
  \}

  showImage('{#imgurl}')
  imgWidth+\"x\"+imgHeight"), "Global")
}

sample-image-properties-002.ubot

 

Kevin

  • Like 2
Link to post
Share on other sites

Cool. That's a lot better.

 

In the posted code there is something missing (what you have in the ubot file):

navigate(#imgurl, "Wait")
 
 
Complete Code:
set(#imgurl, "http://www.selby.com.au/media/catalog/product/u/h/uhf088.jpg", "Global")
navigate(#imgurl, "Wait")
loop(2) {
set(#imginfo, $eval("
var imgHeight
var imgWidth

function findHHandWW() \{
imgHeight = this.height;imgWidth = this.width;return true
\}

function showImage(imgPath) \{
var myImage = new Image()
myImage.name = imgPath
myImage.onload = findHHandWW
myImage.src = imgPath
\}

showImage('{#imgurl}')
imgWidth+\"x\"+imgHeight"), "Global")
}
 
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...