Welcome Guest, Not a member yet? Register   Sign In
url to image: How to create a screenshot from an url?
#1

[eluser]marcox[/eluser]
Hi there,

I'm looking for an piece of php-code or class which creates from a given url an image (jpeg prefered).
It should work this way:

Code:
<?
   $url  = "http://www.example.com/";
   $file = "/your/internal/path/image.jpg";
   create_image_from_url($url, $file);
?>

After executing this or some equivalent code an screenshot of $url should be created on my file system at $file. Does anyone know such a feature?

Greetings,
Marcox
#2

[eluser]jdfwarrior[/eluser]
I dont believe that is done through pure php. I have seen perl scripts and such that do it in the past. Have never seen regular php that does it though.
#3

[eluser]garymardell[/eluser]
It cannot be done through just php, i would look into a service with an api to do it. There are many around. Its not a simple process.
#4

[eluser]marcox[/eluser]
[quote author="jdfwarrior" date="1247618571"]I dont believe that is done through pure php. I have seen perl scripts and such that do it in the past. Have never seen regular php that does it though.[/quote]

Perl would be an alternative... do you have any suggestions in perl for me?
#5

[eluser]marcox[/eluser]
[quote author="garymardell" date="1247618822"]It cannot be done through just php, i would look into a service with an api to do it. There are many around. Its not a simple process.[/quote]

Yes, I've found a windows-tool called HTML2JPG (www.html2jpg.com), but my website is hosted on a linux system - so i need a solution for this OS ;-(
#6

[eluser]marcox[/eluser]
I've found a perl way, but the result isn't the best, because not all embedded pictures an css-files will be used:

Code:
lwp-download http://www.example.com/ >index.html
convert index.html jpgindex.jpg

For this you will need the Imagick Package.
#7

[eluser]garymardell[/eluser]
I'd look at using a site similar to http://www.thumbalizr.com they have an api and set servers to handle all the work, for better screenshots you need a "premium" account though.
#8

[eluser]marcox[/eluser]
[quote author="garymardell" date="1247621997"]I'd look at using a site similar to http://www.thumbalizr.com they have an api and set servers to handle all the work, for better screenshots you need a "premium" account though.[/quote]

My main problem is that i have to create this screenshot depending on an user's input - just like thumbalizr. After creating the screenshot it has to be saved to a file. I work on a linux system with root access so if you have some more hints for me i can try some ways out.
#9

[eluser]garymardell[/eluser]
Well on the site there is the section under api and tools that needs you to signup to get a script to cache images locally. haven't signed up so dont know if its of any use. Is this just a part of your site or the main focus of your site to take images?
#10

[eluser]slowgary[/eluser]
The problem with this is that parsing a webpage is a complex task. It can probably be done in PHP or Perl, but you'd need to basically write your own web browser from the ground up. The alternative is to use an existing browser, and just take a screenshot of what it renders. This is why people usually use a third party because they've already gone through the trouble of setting up a server that runs a GUI, and they run a utility to grab screenshots from a call to the OS.

There is a PHP function that can grab a screenshot, but it's only available on windows. See it here -> http://us.php.net/manual/en/function.ima...screen.php

What about running a VM of windows? Sounds like a PITA though.




Theme © iAndrew 2016 - Forum software by © MyBB