Solved

Save DIV to image file

Posted on 2013-11-27
5
1,944 Views
Last Modified: 2013-12-19
I have an Intranet app using PHP and jpGraph to generate a line chart on my page using data from a database used for tracking production rate versus production goal.

Above the chart, I have text displaying various color-coded metric values.  Below the chart I haev a running tally showing the number of end-of-line defects for the current run.  All of thjis is placed in a single DIV on my page.  There are other divs with other data, but the are not important.

What I am looking for is a way to capture the contents of the chart div (including all text) AS LAYED OUT ON THE SCREEN and save that to an image file on my network for use by other apps.

I essetially want to perform an automated "snipping tool" like Windows 7 has.

Is this possible at all?

Note: I am not using HTML5, so canvas is out as a solution....
0
Comment
Question by:dimmergeek
5 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Why not use HTML5?  It's what everyone is using today!

But that aside, if you use Windows there are some "imagegrab" functions.
http://php.net/manual/en/function.imagegrabwindow.php

Also, you might be able to send the graph to the file system this way:
http://jpgraph.net/doc/faq.php#F2-1
0
 
LVL 7

Author Comment

by:dimmergeek
Comment Utility
Ray, that looks promising, but it also appears to grab the contents of the entire window.  I just want a particular div.  Alternatively, is there a way I can grab the entire window and crop out the area I do not need?
0
 
LVL 12

Expert Comment

by:Cyber-spy
Comment Utility
Are you trying to do this automatically with a script or manually?

If you want to automate it, here is a PowerShell script you can use to screenshot the entire screen or just a windows and save it to a file

http://gallery.technet.microsoft.com/scriptcenter/eeff544a-f690-4f6b-a586-11eea6fc5eb8
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
grab the entire window and crop out the area
Yes, there is this:
http://php.net/manual/en/function.imagecrop.php

If you're on a lower level of PHP, you have imageCopy() but there is some calculation you would need to do.  It's a project that kinds of works in reverse.  Normally PHP is used on the server to generate data (HTML, JS, CSS) that is sent to the client.  When you start trying to use PHP to get client data you're really swimming upstream and it's probably better to look for a different approach.
0
 
LVL 14

Expert Comment

by:jb1dev
Comment Utility
You might also consider using PhantomJS to do this.
http://phantomjs.org/

https://github.com/ariya/phantomjs/wiki/Screen-Capture
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now