473,385 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Convert and save image generated by javascript and css

Hi,
I have a graph generated dynamically according to the data from a database using javascript and css and displayed inside a div of an html page. My question is is there anyway I can convert that graph to image in any of these jpg,png,gif... format. Thank you.
Dec 22 '08 #1
4 5203
Dormilich
8,658 Expert Mod 8TB
you can do that server side (with e.g. PHP). I'm not aware that JS can do that.

regards
Dec 22 '08 #2
gits
5,390 Expert Mod 4TB
for mozilla/FF you could play with the <canvas> element and its special moz-additions ... for a start have a look here at the last section: 'Rendering Web Content Into A Canvas'

kind regards
Dec 22 '08 #3
Hi gits, thank you for your reply. I tried to use the canvas with FF but it gave me an error 'getContext is not a function. Can I pass the output of the graph function directly to the draw() as the image source?
Could you give me some sample codes?
Thank you.
Dec 23 '08 #4
gits
5,390 Expert Mod 4TB
hi ... there is a problem with the privileges ... so you need to request that for your code ... have a look at the following simple example that you could simply test in FF's Firebug-extension:

Expand|Select|Wrap|Line Numbers
  1. netscape.security.PrivilegeManager.enablePrivilege(
  2.     "UniversalXPConnect");
  3.  
  4. var canvas = document.createElement('canvas');
  5.  
  6. canvas.setAttribute('width', 600);
  7.  
  8. canvas.setAttribute('height', 600);
  9.  
  10. var ctx = canvas.getContext("2d");
  11.  
  12. ctx.drawWindow(window, 0, 0, 600, 600, "rgb(0,0,0)");
  13.  
  14. document.lastChild.appendChild(canvas);
  15.  
this will just add a canvas-node with a 600x600px screenshot to a document that is loaded in FF actually when you run it with firebug. note that this code is not really usable for public webapps but for intranet-apps or a personal app you may create easy screenshots this way.

kind regards
Dec 23 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: George Hester | last post by:
http://hesterloli.dnsalias.com/test/javascript_image.htm The image is the 100x100 px block. If we right-click in it and try to save the image we cannot. Is it possible to say set a mime-type so...
1
by: Fritz Switzer | last post by:
With two controls a PictureBox and another "PictureBox like" , Pic2, a control from a dll, I'm stuck on cannot implicity convert System.Drawing.Image to System.Drawing.Bitmap error. How do I...
1
by: James dean | last post by:
The following code is the current method i have for converting an image to Base64.Is this the most efficient way to convert an image to base64 or are there others. The Image class's Save method is...
3
by: Ignacio Marcos | last post by:
Hi all. I need to convert files on my server from gif to jpg format. I tried with the thumb function, but it does not work (on the line thumb.Save(Response.OutputStream,...
4
by: David W. Simmonds | last post by:
Is there a way I can have a button on a ASP.NET form that when clicked will allow the user to save the image to a file on the client side? I know that the user can simply rclick the image and...
7
by: Scott Schluer | last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG) to a B&W photo? Thanks, Scott
2
by: Kenneth Keeley | last post by:
Hi, I am creating a news and events page on my Intranet site and I wish to allow people to upload an image with there news to my site. The text and image are all stored in an SQL database. I have...
0
by: jason | last post by:
I googled a lot, couldn't find a good solution. Any help is greatly appreciated. What I want to do is: Given a web page in a running IE browser , i want to save an image in this web page to...
8
by: platinumhimani | last post by:
-How to convert any image(8,16,24,32 or 64-bit) to 8-bit grayscale -i have tried to convert a 24-bit image to grayscale using setpixel and getpixel functions, in vb.net but i am unable to save...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.