Jump to content




PHP screenshot generator v2 now with color!


  • You cannot reply to this topic
14 replies to this topic

#1 Jan

  • Members
  • 141 posts
  • Locationthe Netherlands

Posted 07 May 2013 - 05:01 PM

Introduction
Today I made a screenshot generator using PHP and GD (an image libarary)
Currently you send the text, and the monitor width and height to my php script on my website, and then it generates an image with it.
It doesnt support color yet.

Screenshot of paint:
Posted Image

Long link:
http://janvanrosmalen.com/ccrender/color/51/19/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++XX+++++++++++++++++++++++++++++++++++++++++++++++++++%5BSave%5D+Exit++++++++++++++++++++++++++++++++++++++++/888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888800888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888400004000000888888888888888888888888888888888888888/000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000033000000000000000000000000000000000000000000000000044000000000000000000000000000000000000000000000000055000000000000000000000000000000000000000000000000066000000000fff0fffffffffffff00000000000000000000000770000fff0f00000000ffff00000ffffff0000000000000000088fff000000000000fff00ff000000000ffff0000000000000099f00000000000000f00000f0000000000000ff000000000000aaf000000000000000fffffff00000000ffffff000000000000bbff00000000000fffff000fffffff0f0000000000000000000cc0fff00000000f0000ff00000ff000f0000000ff0000000000dd000fffff0000f00000ffff0f0fff000000000000000000000ee0000000fffffffff0000ff00000ff00000000000000000000ff0000000000000000ffffffffffffff0fff0fffff0000000000000000000000000000ffff0000000ff0000000000000000000f0888888888888888888888888888888888888888888888888888/13/19/0/8/false/screenshot.png
Now you are probably thinking: how did he generate the link?

How to make a screenshot
1. Install the lua program below
2. Run the screenshot program
3. Run the program you want to take a screenshot from
4. Press f1
5. leave CC, and open your computer files
6. Open screen.txt and copy the link
7. On these forums, click on Image, and paste the link
8. Done!

Posted Image

Lua program v2
It uses gophers buffer redirect API:
http://www.computerc...__hl__gopheratl

Lua code v2:
http://pastebin.com/BCbdfzsY

http://pastebin.com/uPJ066tJ old
pastebin get BCbdfzsY screenshot

Spoiler

For server hosts
Here are the files required to run the generator on your own site
Here is the PHP code (screenshot.php):
Spoiler

Here is the .htaccess (for magic links)
Spoiler


TODO
- color support
- workaround to let images work on these forums (priority!)
fixed! Now I need to update the lua program to produce links using the 'trick'.
- database. After making a screenshot, it will be send via http API.
then a shorter url is returned to minecraft. (will be hard, and needs to be done very secure, to prevent spam and code execution of SQL)

I will not make this probably
- Fix color bugs
Fixed, thanks to Gravity
- Work for non-colored terminals (next update)

License
You are free to use this program, edit it, or host it. You may also integrate it in your OS or whatever you want.
I would like you to post a link to this thread if you use screenshots generated with this :)

If you have any improvements, please post them. Have fun with the screenshots!

#2 D3matt

  • Members
  • 830 posts

Posted 07 May 2013 - 05:39 PM

Awesome!

You should be able to use a .png extension for the file and still have it work. Just have it ignore .php at the end of the string and add it that way.

#3 Jan

  • Members
  • 141 posts
  • Locationthe Netherlands

Posted 07 May 2013 - 05:51 PM

View PostD3matt, on 07 May 2013 - 05:39 PM, said:

Awesome!

You should be able to use a .png extension for the file and still have it work. Just have it ignore .php at the end of the string and add it that way.
Yes i found a way using .htaccess to do so.
http://corz.org/serv...s/htaccess2.php
It transforms:
trick/51/19/text.png
to:
screenshot.php?w=51&h=19&t=text
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^trick/([^/]+)/([^/]+)/([^/]+).png screenshot.php?w=$1&h=$2&t=$3 [NC]
DirectoryIndex screenshot.php
i'll update the lua program tomorrow I think

#4 D3matt

  • Members
  • 830 posts

Posted 07 May 2013 - 06:19 PM

Ah yes, htaccess. Wonderous thing.

#5 Jan

  • Members
  • 141 posts
  • Locationthe Netherlands

Posted 08 May 2013 - 07:14 AM

Large update: added workaround for the forums, color support, and cursor rendering (it will always be rendered, even if blink is off)

#6 superaxander

  • Members
  • 609 posts
  • LocationHolland

Posted 08 May 2013 - 07:17 AM

Nice!

#7 Jan

  • Members
  • 141 posts
  • Locationthe Netherlands

Posted 08 May 2013 - 08:43 AM

There appears to be a bug when using non-colored displays. It directly leaves the program...
To fix this,line 238 should be:
local buff = createRedirectBuffer(w,h,colors.white,colors.black)
instead of:
local buff = createRedirectBuffer(w,h,colors.white,colors.black,true)

there are probably other bugs so I'll wait with updating the program

#8 GravityScore

  • Members
  • 796 posts
  • LocationLand of Meh

Posted 08 May 2013 - 08:49 AM

View PostJan, on 07 May 2013 - 05:01 PM, said:

If you know the (RGB) values (decimal) of CC, please post them, thanks

Here you go, already formatted as Java strings, in RGB form, separated by commas:
colors = new String[16];
colors[15] = "255,255,255"; // White
colors[14] = "235,136,68";  // Orange
colors[13] = "195,84,205";  // Magenta
colors[12] = "102,137,211"; // Light blue
colors[11] = "222,222,108"; // Yellow
colors[10] = "65,205,52"; // Lime
colors[9] = "216,129,152";  // Pink
colors[8] = "67,67,67";  // Gray
colors[7] = "153,153,153";  // Light gray
colors[6] = "40,118,151";   // Cyan
colors[5] = "123,47,190";   // Purple
colors[4] = "37,49,146"; // Blue
colors[3] = "81,48,26";  // Brown
colors[2] = "59,81,26";  // Green
colors[1] = "179,49,44"; // Red
colors[0] = "0,0,0";  // Black

Not in decimal sorry, but you can just input these values, and divide them by 255.

EDIT: also, the font you're using isn't the same as CC's. CC uses the default Minecraft font, and a replica can be found here.

#9 Jan

  • Members
  • 141 posts
  • Locationthe Netherlands

Posted 08 May 2013 - 08:52 AM

View PostGravityScore, on 08 May 2013 - 08:49 AM, said:

View PostJan, on 07 May 2013 - 05:01 PM, said:

If you know the (RGB) values (decimal) of CC, please post them, thanks

Here you go, already formatted as Java strings, in RGB form, separated by commas:
colors = new String[16];
colors[15] = "255,255,255"; // White
colors[14] = "235,136,68";  // Orange
colors[13] = "195,84,205";  // Magenta
colors[12] = "102,137,211"; // Light blue
colors[11] = "222,222,108"; // Yellow
colors[10] = "65,205,52"; // Lime
colors[9] = "216,129,152";  // Pink
colors[8] = "67,67,67";  // Gray
colors[7] = "153,153,153";  // Light gray
colors[6] = "40,118,151";   // Cyan
colors[5] = "123,47,190";   // Purple
colors[4] = "37,49,146"; // Blue
colors[3] = "81,48,26";  // Brown
colors[2] = "59,81,26";  // Green
colors[1] = "179,49,44"; // Red
colors[0] = "0,0,0";  // Black

Not in decimal sorry, but you can just input these values, and divide them by 255.
Thank you very much! I am now inserting them in the PHP script.
Oh and with decimal I meant it like 'not in hexadecimal'

#10 GravityScore

  • Members
  • 796 posts
  • LocationLand of Meh

Posted 08 May 2013 - 08:54 AM

View PostJan, on 08 May 2013 - 08:52 AM, said:

Oh and with decimal I meant it like 'not in hexadecimal'

Oh I see :P Also, read the edit about fonts :P

#11 Jan

  • Members
  • 141 posts
  • Locationthe Netherlands

Posted 08 May 2013 - 09:28 AM

View PostGravityScore, on 08 May 2013 - 08:54 AM, said:

View PostJan, on 08 May 2013 - 08:52 AM, said:

Oh and with decimal I meant it like 'not in hexadecimal'

Oh I see :P Also, read the edit about fonts :P
Good idea about the fonts, I implemented it.
Now I need to make it 'pixel perfect'. Also, some letters arent centered :/
EDIT: going to fix it...

#12 diegodan1893

  • Members
  • 164 posts
  • LocationSpain

Posted 08 May 2013 - 12:51 PM

Nice! I was looking for something like this for my program.

Suggestion: can you increase the image size to be the same as ComputerCraft term?

#13 Left4Cake

  • Members
  • 272 posts
  • LocationEarth

Posted 08 May 2013 - 01:00 PM

Posted Image

#14 Jan

  • Members
  • 141 posts
  • Locationthe Netherlands

Posted 08 May 2013 - 02:05 PM

View Postdiegodan1893, on 08 May 2013 - 12:51 PM, said:

Nice! I was looking for something like this for my program.

Suggestion: can you increase the image size to be the same as ComputerCraft term?

View PostLeft4Cake, on 08 May 2013 - 01:00 PM, said:

Posted Image
Thanks :)
The size of the image is actually the same size as the monitor in-game (when you make the minecraftwindow smaller)
You probably meant scaling?

#15 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 08 May 2013 - 02:11 PM

oh god long urls, y u no base64
nice rendering code :3





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users