Hi,
I have a table (100 x 100 - coming out of a database) with every cell filled with a different color. Is there a way using a php function so the client actually see the table as an image?
Is there a way to make a snapshot of the table using a script or something like that?
Thanks,
Convert html table to an image using php
Moderator: General Moderators
Re: Convert html table to an image using php
You have two options, you either use an HTML table, or a series of spans floated left.
In either case, you just makes the pixel data up with a HTML element, and simply format it with 'width: 1px; line-height: 1px; font-size: 1px; background-color: $something' . Now if you're going with the floating solution, you need to add 'display: block' to the spans. When you're using a table, make sure to set the cellpadding and cellspacing to 0, so that you don't have the gap between pixels.
In either case, you just makes the pixel data up with a HTML element, and simply format it with 'width: 1px; line-height: 1px; font-size: 1px; background-color: $something' . Now if you're going with the floating solution, you need to add 'display: block' to the spans. When you're using a table, make sure to set the cellpadding and cellspacing to 0, so that you don't have the gap between pixels.
Re: Convert html table to an image using php
Thanks for the suggestion. However, if I want to create a really large table like 10000 cells, the web page will become too large and then I would like to first let the client see a snapshot.
then the client can click on an link which will show a smaller area of the table and allow him to choose cell. Therefore, I fear that I have to find some solution of creating a snapshot. Any suggestions?
then the client can click on an link which will show a smaller area of the table and allow him to choose cell. Therefore, I fear that I have to find some solution of creating a snapshot. Any suggestions?
Re: Convert html table to an image using php
So... let me make sure i have this strait. You have a 1000 x 1000 px image saved into your database. You then are trying to output it as a 100 x 100 image? Alright, why is the images stored like that in the database. It sounds like a bad design personally.
However, if you're actually trying to do that, you're going to have to do image manipulation. That's a little beyond my realm of expertise. You'd have to take a sample of every 10 px, and then factor in the pixels you're removing to calculate what the color should be for the remaining pixel. Sadly, I don't remember the specifics of the algorithm involved beyond that point.
However, if you're actually trying to do that, you're going to have to do image manipulation. That's a little beyond my realm of expertise. You'd have to take a sample of every 10 px, and then factor in the pixels you're removing to calculate what the color should be for the remaining pixel. Sadly, I don't remember the specifics of the algorithm involved beyond that point.
Re: Convert html table to an image using php
If you can get one php html to image converter it will help.