motho 0 Posted January 23, 2014 Report Share Posted January 23, 2014 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 Quote Link to post Share on other sites
Bot-Factory 602 Posted January 24, 2014 Report Share Posted January 24, 2014 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.http://www.imagemagick.org/ 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. CheersDan Quote Link to post Share on other sites
k1lv9h 76 Posted January 24, 2014 Report Share Posted January 24, 2014 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 2 Quote Link to post Share on other sites
Bot-Factory 602 Posted January 25, 2014 Report Share Posted January 25, 2014 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 imgHeightvar imgWidthfunction findHHandWW() \{imgHeight = this.height;imgWidth = this.width;return true\}function showImage(imgPath) \{var myImage = new Image()myImage.name = imgPathmyImage.onload = findHHandWWmyImage.src = imgPath\}showImage('{#imgurl}')imgWidth+\"x\"+imgHeight"), "Global")} 1 Quote Link to post Share on other sites
k1lv9h 76 Posted January 25, 2014 Report Share Posted January 25, 2014 Hi, @dan Where is the loop for a count of 0 that the navigate command is in. No matter updated .ubot file to match code. Kevin Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.