Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2014 NTU IM prepConf 哞~有趣的圖文產生器

Shouko
October 05, 2014

2014 NTU IM prepConf 哞~有趣的圖文產生器

Shouko

October 05, 2014
Tweet

More Decks by Shouko

Other Decks in Programming

Transcript

  1. <?php // credits to http://www.mpgh.net/forum/showthread.php?t=368936 $ip = $_SERVER['REMOTE_ADDR']; $my_img =

    imagecreate( 250, 80 ); $background = imagecolorallocate( $my_img, 255, 255, 255 ); $text_colour = imagecolorallocate( $my_img, 78, 78, 78 ); $line_colour = imagecolorallocate( $my_img, 128, 255, 0 ); imagestring( $my_img, 4, 30, 25, "Your IP Is: $ip", $text_colour ); imagesetthickness ( $my_img, 7 ); imageline( $my_img, 30, 45, 220, 45, $line_colour ); header( "Content-type: image/png" ); imagepng( $my_img ); imagecolordeallocate( $line_color ); imagecolordeallocate( $text_color ); imagecolordeallocate( $background ); imagedestroy( $my_img ); https://gist.github.com/shouko/4e8087f1c559187b21f9 Generating image dynamically using PHP + GD
  2. How to implement the generating process Advantages Disadvantages At Server

    Side ( PHP + GD ) Quality is consistent High cost for hosting website At Client Side ( HTML5 + JavaScript ) Low cost Might not have same result on different devices