1

I have a server side script that gets the HTML contents of a URL. I need it to get the computed width of elements (specifically images) as the browser would render if with all the CSS attributes applied to it. Something that will do what qQuery's .width method does but in PHP.

Are there any libraries out there capable of doing this? I've heard of Rhino but I am not sure if it has this specific capability.

Tony Paternite
  • 153
  • 1
  • 14
  • Possible duplicate: http://stackoverflow.com/questions/9732114/convert-html-to-image-in-php – Mike Feb 22 '13 at 21:19
  • That is a really tough task. Even with node.js I see there is no solution for this yet (http://stackoverflow.com/a/9121925/779320). I think you should find a work-around to achieve your goal. – ihsan Feb 23 '13 at 02:04
  • Thanks @ihsan. I decided to go with a workaround. I'm trying to get the most relevant image from any given URL (usually news articles). I decided to use the Boilerpipe API to strip out only the article and find images within that. – Tony Paternite Feb 25 '13 at 03:09

1 Answers1

0

The moment something is rendered you have absolute no control of it on PHP, it simples does not know how it was set on the page. What you would have to do is calculate it in javascript and send back that data to PHP through an ajax call.

Yohan Leafheart
  • 860
  • 1
  • 11
  • 27
  • He's using a script to get the contents of a URL. It doesn't matter how the contents were set. – Mike Feb 22 '13 at 21:21