-1

Im trying to make a Image to CSS convertor, which works in PHP.

I have tried looking at the javascript convertor at: http://codepen.io/blazeeboy/pen/bCaLE

I see that it make it into a canvas element and scans each pixels for the color, which would not make it possible the same way in PHP.

hakre
  • 193,403
  • 52
  • 435
  • 836
Mark Topper
  • 339
  • 1
  • 6
  • 14
  • 2
    are you looking to base64 encode the image? – pzirkind Jan 03 '13 at 21:51
  • If you're looking to create Data URIs (see [examples](http://en.wikipedia.org/wiki/Data_URI_scheme#Examples)), then all you need to do in PHP is use `base64_encode` (see [discussion](http://php.net/manual/en/function.base64-encode.php#110868)). You won't need to read the pixel data, because you're just converting the image file to a ASCII format. – thirdender Jan 03 '13 at 22:00
  • 1
    If you are trying to base64 encode an image for use in css, this link may be helpful: http://stackoverflow.com/questions/35879/base64-encoding-image – Supericy Jan 03 '13 at 22:01
  • No, it is not just base64 encoding. – Mark Topper Jan 04 '13 at 13:47

1 Answers1

5

You can use PHP's GD2 functions, such as imagecreatefrompng and imagecolorat.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592