isaacg1 / pyth

Pyth, an extremely concise language. Try it here:
https://pyth.herokuapp.com/
MIT License
263 stars 57 forks source link

Added image I/O #120

Closed Maltysen closed 9 years ago

Maltysen commented 9 years ago

A huge roadblock to pyth participating in many challenges was image i/o. In many cases it was impossible, and even when ppm was allowed, headers and formatting kills your score when both parsing and generating. So I added native image support to ' and .w with PIL.

' detects image file names and makes a nested array. It removes alpha when all 255 and condenses grayscale tuples into a single value.

.w detects arrays and does the reverse in regards to alpha and grayscale. I also changed the default filename behavior in .w. It now first creates a filename-prefix, defaulting to "o" which you can override by passing in like "foo"and then a suffix which defaults to .png and .txt. You cant override just suffix, but you both as expected like "foo.jpg".

A possible improvement that might be disruptive is on .w to take grayscale images with only 0 and 1 as values and assume B&W and make the 1's 255's, and the opposite on '.