text:
Encode Images into Tweets (Extreme Image Compression Edition)
Based on the very successful Twitter image encoding challenge at Stack Overflow.
If an image is worth 1000 words, how much of an image can you fit in 114.97 bytes?
I challenge you to come up with a general-purpose method to compress images into a standard Twitter comment that contains only printable ASCII text.
Rules:

You must write a program that can take an image and output the encoded text.
The text created by the program must be at most 140 characters long and must only contain characters whose code points are in the range of 32-126, inclusive.
You must write a program (possibly the same program) that can take the encoded text and output a decoded version of the photograph.
Your program can use external libraries and files, but cannot require an internet connection or a connection to other computers.
The decoding process cannot access or contain the original images in any way.
Your program must accept images in at least one of these formats (not necessarily more): Bitmap, JPEG, GIF, TIFF, PNG. If some or all of the sample images are not in the correct format, you can convert them yourself prior to compression by your program.

Judging:
This is a somewhat subjective challenge, so the winner will (eventually) be judged by me. I will focus my judgment on a couple of important factors, listed below in decreasing importance:

Ability to do a reasonable job of compressing a wide variety of images, including those not listed as a sample image
Ability to preserve the outlines of the major elements in an image
Ability to compress the colors of the major elements in an image
Ability to preserve outlines and colors of the minor details in an image
Compression time. Although not as important as how well an image is compressed, faster programs are better than slower programs that do the same thing.

Your submission should include the resulting images after decompression, along with the Twitter comment generated.  If possible, you could also give a link to the source code.
Sample images:
The Hindenburg,
Mountainous Landscape,
Mona Lisa,
2D Shapes

U+007F (127) and U+0080 (128) are control characters. I would suggest banning those as well.

Good observation.  I will fix that.

Doesn't Twitter allow Unicode to some extent?

Any limit on the input image resolution?

I feel like I would want to patent a solution to this.

@marinus To some extent, yes, but I excluded them in order to differentiate this challenge, and also because Twitter counts Unicode characters in a very convoluted way.

@Sir_Lagsalot I won't require anything larger than the sample Mona Lisa image.

I really do not understand what I'm supposed to be doing at all... I think I've read this 15 times. I'm supposed to write a program to compress the image into a 140byte string, then convert strings into compressed images?

@jdstankosky The goal is to basically compress the image into a 140-char string, and then decompress it into back an image. The whole process is of course going to be extremely lossy, so the goal is to have the best possible final image.

So, this is a subjective winning criteria? Is this popularity (highest votes) challenge? I will give it my best shot. I've got some learning to do...

It seems that the website for "Mountainous Landscapes" has been disabled due to the recent WordPress attacks - if someone has saved the large version on disk, uploading it somewhere would be useful. I don't know what the original size was, but for now,  http://i.stack.imgur.com/iSWFn.jpg seems to be the biggest version left (341 x 256).

"Mountainous Landscapes" 1024x768 - Get it before it's gone! --> http://i.imgur.com/VaCzpRL.jpg <--

LenPEG.

I've improved my method by adding actual compression. It now operates by iteratively doing the following:

Convert the image to YUV
Downsize the image preserving the aspect ratio (if the image is color, the chroma is sampled at 1/3 the width & height of the luminance)
Reduce the bit depth to 4 bits per sample
Apply median prediction to the image, making the sample distribution more uniform
Apply adaptive range compression to the image.
See if the size of the compressed image is <= 112

The largest image that fits in the 112 bytes is then used as the final image, with the remaining two bytes used to store the width & height of the compressed image, plus a flag indicating if the image is in color. For decoding, the process is reversed, and the image scaled up so the smaller dimension is 128.
There is some room for improvement, namely not all the available bytes are used typically, but I feel I'm at the point of significantly diminishing returns for downsampling + lossless compression.
Quick & dirty C++ source
Windows exe
Mona Lisa (13x20 luminance, 4x6 chroma)
&Jhmi8(,x6})Y"f!JC1jTzRh}$A7ca%/B~jZ?[_I17+91j;0q';|58yvX}YN426@"97W8qob?VB'_Ps`x%VR=H&3h8K=],4Bp=$K=#"v{thTV8^~lm vMVnTYT3rw N%I

Hindenburg (21x13 luminance)
GmL<B&ep^m40dPs%V[4&"~F[Yt-sNceB6L>Cs#/bv`\4{TB_P Rr7Pjdk7}<*<{2=gssBkR$>!['ROG6Xs{AEtnP=OWDP6&h{^l+LbLr4%R{15Zc<D?J6<'#E.(W*?"d9wdJ'

Mountains (19x14 luminance, 6x4 chroma)
Y\Twg]~KC((s_P>,*cePOTM_X7ZNMHhI,WeN(m>"dVT{+cXc?8n,&m$TUT&g9%fXjy"A-fvc 3Y#Yl-P![lk~;.uX?a,pcU(7j?=HW2%i6fo@Po DtT't'(a@b;sC7"/J

2D Shapes (21x15 luminance, 7x5 chroma)
n@|~c[#w<Fv8mD}2LL!g_(~CO&MG+u><-jT#{KXJy/``#S@m26CQ=[zejo,gFk0}A%i4kE]N ?R~^8!Ki*KM52u,M(his+BxqDCgU>ul*N9tNb\lfg}}n@HhX77S@TZf{k<CO69!

This makes me feel like I'm developing cataracts or something. Haha, great job!

Nice improvements!

Go
Works by dividing the image into regions recursively.  I try to divide regions with high information content, and pick the dividing line to maximize the difference in color between the two regions.
Each division is encoded using a few bits to encode the dividing line.  Each leaf region is encoded as a single color.

4vN!IF$+fP0~\}:0d4a's%-~@[Q(qSd<<BDb}_s|qb&8Ys$U]t0mc]|! -FZO=PU=ln}TYLgh;{/"A6BIER|{lH1?ZW1VNwNL 6bOBFOm~P_pvhV)]&[p%GjJ ,+&!p"H4`Yae@:P

<uc}+jrsxi!_:GXM!'w5J)6]N)y5jy'9xBm8.A9LD/^]+t5#L-6?9 a=/f+-S*SZ^Ch07~s)P("(DAc+$[m-:^B{rQTa:/3`5Jy}AvH2p!4gYR>^sz*'U9(p.%Id9wf2Lc+u\&\5M>

lO6>v7z87n;XsmOW^3I-0'.M@J@CLL[4z-Xr:! VBjAT,##6[iSE.7+as8C.,7uleb=|y<t7sm$2z)k&dADF#uHXaZCLnhvLb.%+b(OyO$-2GuG~,y4NTWa=/LI3Q4w7%+Bm:!kpe&

ZoIMHa;v!]&j}wr@MGlX~F=(I[cs[N^M`=G=Avr*Z&Aq4V!c6>!m@~lJU:;cr"Xw!$OlzXD$Xi>_|*3t@qV?VR*It4gB;%>,e9W\1MeXy"wsA-V|rs$G4hY!G:%v?$uh-y~'Ltd.,(

The Hindenburg picture looks pretty crappy, but the others I like.
package main

import (
    "os"
    "image"
    "image/color"
    "image/png"
    _ "image/jpeg"
    "math"
    "math/big"
)

// we have 919 bits to play with: floor(log_2(95^140))

// encode_region(r):
//   0
//      color of region (12 bits, 4 bits each color)
// or
//   1
//      dividing line through region
//        2 bits - one of 4 anchor points
//        4 bits - one of 16 angles
//      encode_region(r1)
//      encode_region(r2)
//
// start with single region
// pick leaf region with most contrast, split it

type Region struct {
    points []image.Point
    anchor int  // 0-3
    angle int // 0-15
    children [2]*Region
}

// mean color of region
func (region *Region) meanColor(img image.Image) (float64, float64, float64) {
    red := 0.0
    green := 0.0
    blue := 0.0
    num := 0
    for _, p := range region.points {
        r, g, b, _ := img.At(p.X, p.Y).RGBA()
        red += float64(r)
        green += float64(g)
        blue += float64(b)
        num++
    }
    return red/float64(num), green/float64(num), blue/float64(num)
}

// total non-uniformity in region's color
func (region *Region) deviation(img image.Image) float64 {
    mr, mg, mb := region.meanColor(img)
    d := 0.0
    for _, p := range region.points {
        r, g, b, _ := img.At(p.X, p.Y).RGBA()
        fr, fg, fb := float64(r), float64(g), float64(b)
        d += (fr - mr) * (fr - mr) + (fg - mg) * (fg - mg) + (fb - mb) * (fb - mb)
    }
    return d
}

// centroid of region
func (region *Region) centroid() (float64, float64) {
    cx := 0
    cy := 0
    num := 0
    for _, p := range region.points {
        cx += p.X
        cy += p.Y
        num++
    }
    return float64(cx)/float64(num), float64(cy)/float64(num)
}

// a few points in (or near) the region.
func (region *Region) anchors() [4][2]float64 {
    cx, cy := region.centroid()

    xweight := [4]int{1,1,3,3}
    yweight := [4]int{1,3,1,3}
    var result [4][2]float64
    for i := 0; i < 4; i++ {
        dx := 0
        dy := 0
        numx := 0
        numy := 0
        for _, p := range region.points {
            if float64(p.X) > cx {
                dx += xweight[i] * p.X
                numx += xweight[i]
            } else {
                dx += (4 - xweight[i]) * p.X
                numx += 4 - xweight[i]
            }
            if float64(p.Y) > cy {
                dy += yweight[i] * p.Y
                numy += yweight[i]
            } else {
                dy += (4 - yweight[i]) * p.Y
                numy += 4 - yweight[i]
            }
        }
        result[i][0] = float64(dx) / float64(numx)
        result[i][1] = float64(dy) / float64(numy)
    }
    return result
}

func (region *Region) split(img image.Image) (*Region, *Region) {
    anchors := region.anchors()
    // maximize the difference between the average color on the two sides
    maxdiff := 0.0
    var maxa *Region = nil
    var maxb *Region = nil
    maxanchor := 0
    maxangle := 0
    for anchor := 0; anchor < 4; anchor++ {
        for angle := 0; angle < 16; angle++ {
            sin, cos := math.Sincos(float64(angle) * math.Pi / 16.0)
            a := new(Region)
            b := new(Region)
            for _, p := range region.points {
                dx := float64(p.X) - anchors[anchor][0]
                dy := float64(p.Y) - anchors[anchor][1]
                if dx * sin + dy * cos >= 0 {
                    a.points = append(a.points, p)
                } else {
                    b.points = append(b.points, p)
                }
            }
            if len(a.points) == 0 || len(b.points) == 0 {
                continue
            }
            a_red, a_green, a_blue := a.meanColor(img)
            b_red, b_green, b_blue := b.meanColor(img)
            diff := math.Abs(a_red - b_red) + math.Abs(a_green - b_green) + math.Abs(a_blue - b_blue)
            if diff >= maxdiff {
                maxdiff = diff
                maxa = a
                maxb = b
                maxanchor = anchor
                maxangle = angle
            }
        }
    }
    region.anchor = maxanchor
    region.angle = maxangle
    region.children[0] = maxa
    region.children[1] = maxb
    return maxa, maxb
}

// split regions take 7 bits plus their descendents
// unsplit regions take 13 bits
// so each split saves 13-7=6 bits on the parent region
// and costs 2*13 = 26 bits on the children, for a net of 20 bits/split
func (region *Region) encode(img image.Image) []int {
    bits := make([]int, 0)
    if region.children[0] != nil {
        bits = append(bits, 1)
        d := region.anchor
        a := region.angle
        bits = append(bits, d&1, d>>1&1)
        bits = append(bits, a&1, a>>1&1, a>>2&1, a>>3&1)
        bits = append(bits, region.children[0].encode(img)...)
        bits = append(bits, region.children[1].encode(img)...)
    } else {
        bits = append(bits, 0)
        r, g, b := region.meanColor(img)
        kr := int(r/256./16.)
        kg := int(g/256./16.)
        kb := int(b/256./16.)
        bits = append(bits, kr&1, kr>>1&1, kr>>2&1, kr>>3)
        bits = append(bits, kg&1, kg>>1&1, kg>>2&1, kg>>3)
        bits = append(bits, kb&1, kb>>1&1, kb>>2&1, kb>>3)
    }
    return bits
}

func encode(name string) []byte {
    file, _ := os.Open(name)
    img, _, _ := image.Decode(file)

    // encoding bit stream
    bits := make([]int, 0)

    // start by encoding the bounds
    bounds := img.Bounds()
    w := bounds.Max.X - bounds.Min.X
    for ; w > 3; w >>= 1 {
        bits = append(bits, 1, w & 1)
    }
    bits = append(bits, 0, w & 1)
    h := bounds.Max.Y - bounds.Min.Y
    for ; h > 3; h >>= 1 {
        bits = append(bits, 1, h & 1)
    }
    bits = append(bits, 0, h & 1)

    // make new region containing whole image
    region := new(Region)
    region.children[0] = nil
    region.children[1] = nil
    for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
        for x := bounds.Min.X; x < bounds.Max.X; x++ {
            region.points = append(region.points, image.Point{x, y})
        }
    }

    // split the region with the most contrast until we're out of bits.
    regions := make([]*Region, 1)
    regions[0] = region
    for bitcnt := len(bits) + 13; bitcnt <= 919-20; bitcnt += 20 {
        var best_reg *Region
        best_dev := -1.0
        for _, reg := range regions {
            if reg.children[0] != nil {
                continue
            }
            dev := reg.deviation(img)
            if dev > best_dev {
                best_reg = reg
                best_dev = dev
            }
        }
        a, b := best_reg.split(img)
        regions = append(regions, a, b)
    }

    // encode regions
    bits = append(bits, region.encode(img)...)

    // convert to tweet
    n := big.NewInt(0)
    for i := 0; i < len(bits); i++ {
        n.SetBit(n, i, uint(bits[i]))
    }
    s := make([]byte,0)
    r := new(big.Int)
    for i := 0; i < 140; i++ {
        n.DivMod(n, big.NewInt(95), r)
        s = append(s, byte(r.Int64() + 32))
    }
    return s
}

// decodes and fills in region.  returns number of bits used.
func (region *Region) decode(bits []int, img *image.RGBA) int {
    if bits[0] == 1 {
        anchors := region.anchors()
        anchor := bits[1] + bits[2]*2
        angle := bits[3] + bits[4]*2 + bits[5]*4 + bits[6]*8
        sin, cos := math.Sincos(float64(angle) * math.Pi / 16.)
        a := new(Region)
        b := new(Region)
        for _, p := range region.points {
            dx := float64(p.X) - anchors[anchor][0]
            dy := float64(p.Y) - anchors[anchor][1]
            if dx * sin + dy * cos >= 0 {
                a.points = append(a.points, p)
            } else {
                b.points = append(b.points, p)
            }
        }
        x := a.decode(bits[7:], img)
        y := b.decode(bits[7+x:], img)
        return 7 + x + y
    }
    r := bits[1] + bits[2]*2 + bits[3]*4 + bits[4]*8
    g := bits[5] + bits[6]*2 + bits[7]*4 + bits[8]*8
    b := bits[9] + bits[10]*2 + bits[11]*4 + bits[12]*8
    c := color.RGBA{uint8(r*16+8), uint8(g*16+8), uint8(b*16+8), 255}
    for _, p := range region.points {
        img.Set(p.X, p.Y, c)
    }
    return 13
}

func decode(name string) image.Image {
    file, _ := os.Open(name)
    length, _ := file.Seek(0, 2)
    file.Seek(0, 0)
    tweet := make([]byte, length)
    file.Read(tweet)

    // convert to bit string
    n := big.NewInt(0)
    m := big.NewInt(1)
    for _, c := range tweet {
        v := big.NewInt(int64(c - 32))
        v.Mul(v, m)
        n.Add(n, v)
        m.Mul(m, big.NewInt(95))
    }
    bits := make([]int, 0)
    for ; n.Sign() != 0; {
        bits = append(bits, int(n.Int64() & 1))
        n.Rsh(n, 1)
    }
    for ; len(bits) < 919; {
        bits = append(bits, 0)
    }

    // extract width and height
    w := 0
    k := 1
    for ; bits[0] == 1; {
        w += k * bits[1]
        k <<= 1
        bits = bits[2:]
    }
    w += k * (2 + bits[1])
    bits = bits[2:]
    h := 0
    k = 1
    for ; bits[0] == 1; {
        h += k * bits[1]
        k <<= 1
        bits = bits[2:]
    }
    h += k * (2 + bits[1])
    bits = bits[2:]

    // make new region containing whole image
    region := new(Region)
    region.children[0] = nil
    region.children[1] = nil
    for y := 0; y < h; y++ {
        for x := 0; x < w; x++ {
            region.points = append(region.points, image.Point{x, y})
        }
    }

    // new image
    img := image.NewRGBA(image.Rectangle{image.Point{0, 0}, image.Point{w, h}})

    // decode regions
    region.decode(bits, img)

    return img
}

func main() {
    if os.Args[1] == "encode" {
        s := encode(os.Args[2])
        file, _ := os.Create(os.Args[3])
        file.Write(s)
        file.Close()
    }
    if os.Args[1] == "decode" {
        img := decode(os.Args[2])
        file, _ := os.Create(os.Args[3])
        png.Encode(file, img)
        file.Close()
    }
}

+1 Those look really stylish! Also, programmed in Go :)

Dude, those look cool.

Oh Gosh that is AWESOME.

Wait, where's your strings?

This is my favorite so far.

That is absolutely phenomenal!

+1 for the Cubist look.

could you add the original images to your answer for comparison?

Python
Encoding requires numpy, SciPy and scikit-image.
Decoding requires only PIL.
This is a method based on superpixel interpolation. To begin, each image is divided into 70 similar sized regions of similar color. For example, the landscape picture is divided in the following manner:

The centroid of each region is located (to the nearest raster point on a grid containing no more than 402 points), as well as it's average color (from a 216 color palette), and each of these regions is encoded as a number from 0 to 86832, capable of being stored in 2.5 printable ascii characters (actually 2.497, leaving just enough room to encode for a greyscale bit).
If you're attentive, you may have noticed that 140 / 2.5 = 56 regions, and not 70 as I stated earlier. Notice, however, that each of these regions is a unique, comparable object, which may be listed in any order. Because of this, we can use the permutation of the first 56 regions to encode for the other 14, as well as having a few bits left over to store the aspect ratio.
More specifically, each of the additional 14 regions is converted to a number, and then each of these numbers concatenated together (multiplying the current value by 86832, and adding the next). This (gigantic) number is then converted to a permutation on 56 objects.
For example:
from my_geom import *

# this can be any value from 0 to 56!, and it will map unambiguously to a permutation
num = 595132299344106583056657556772129922314933943196204990085065194829854239
perm = num2perm(num, 56)
print perm
print perm2num(perm)

will output:
[0, 3, 33, 13, 26, 22, 54, 12, 53, 47, 8, 39, 19, 51, 18, 27, 1, 41, 50, 20, 5, 29, 46, 9, 42, 23, 4, 37, 21, 49, 2, 6, 55, 52, 36, 7, 43, 11, 30, 10, 34, 44, 24, 45, 32, 28, 17, 35, 15, 25, 48, 40, 38, 31, 16, 14]
595132299344106583056657556772129922314933943196204990085065194829854239

The resulting permutation is then applied to the original 56 regions. The original number (and thus the additional 14 regions) can likewise be extracted by converting the permutation of the 56 encoded regions into its numerical representation.
When the --greyscale option is used with the encoder, 94 regions are used instead (separated 70, 24), with 558 raster points, and 16 shades of grey.
When decoding, each of these regions is treated as a 3D cone extended into infinity, with its vertex at the centroid of the region, as viewed from above (a.k.a. a Voronoi Diagram). The borders are then blended together to create the final product.
Future Improvements

The dimensions of the Mona Lisa are a bit off, due to the way I'm storing the aspect ratio. I'll need to use a different system. Fixed, by assuming that the original aspect ratio is somewhere between 1:21 and 21:1, which I think is a reasonable assumption.
The Hindenburg could be improved a lot. The color palette I'm using only has 6 shades of grey. If I introduced a greyscale-only mode, I could use the extra information to increase the color depth, number of regions, number of raster points, or any combination of the three. I've added a --greyscale option to the encoder, which does all three.
2d Shapes would probably look better with blending turned off. I'll likely add a flag for that. Added an encoder option to control the segmentation ratio, and a decoder option to turn off blending.
More fun with combinatorics. 56! is actually large enough to store 15 additional regions, and 15! is large enough to store 2 more for a grand total of 73. But wait, there's more! The partitioning of these 73 object could also be used to store more information. For example, there are 73 choose 56 ways to select the initial 56 regions, and then 17 choose 15 ways to select the next 15. A grand total of 2403922132944423072 partitionings, big enough to store 3 more regions for a total of 76. I'd need to come up with a clever way to uniquely number all partitions of 73 into groups of 56, 15, 2 ... and back. Perhaps not practical, but an interesting problem to think about.

0VW*`Gnyq;c1JBY}tj#rOcKm)v_Ac\S.r[>,Xd_(qT6 >]!xOfU9~0jmIMG{hcg-'*a.s<X]6*%U5>/FOze?cPv@hI)PjpK9\iA7P ]a-7eC&ttS[]K>NwN-^$T1E.1OH^c0^"J 4V9X

0Jc?NsbD#1WDuqT]AJFELu<!iE3d!BB>jOA'L|<j!lCWXkr:gCXuD=D\BL{gA\ 8#*RKQ*tv\\3V0j;_4|o7>{Xage-N85):Q/Hl4.t&'0pp)d|Ry+?|xrA6u&2E!Ls]i]T<~)58%RiA

and
4PV 9G7X|}>pC[Czd!5&rA5 Eo1Q\+m5t:r#;H65NIggfkw'h4*gs.:~<bt'VuVL7V8Ed5{`ft7e>HMHrVVUXc.{#7A|#PBm,i>1B781.K8>s(yUV?a<*!mC@9p+Rgd<twZ.wuFnN dp

The second one encoded with the --greyscale option.

3dVY3TY?9g+b7!5n`)l"Fg H$ 8n?[Q-4HE3.c:[pBBaH`5'MotAj%a4rIodYO.lp$h a94$n!M+Y?(eAR,@Y*LiKnz%s0rFpgnWy%!zV)?SuATmc~-ZQardp=?D5FWx;v=VA+]EJ(:%

Encoded with the --greyscale option.

.9l% Ge<'_)3(`DTsH^eLn|l3.D_na,,sfcpnp{"|lSv<>}3b})%m2M)Ld{YUmf<Uill,*:QNGk,'f2; !2i88T:Yjqa8\Ktz4i@h2kHeC|9,P` v7Xzd Yp&z:'iLra&X&-b(g6vMq

Encoded with --ratio 60, and decoded with --no-blending options.

encoder.py
from __future__ import division
import argparse, numpy
from skimage.io import imread
from skimage.transform import resize
from skimage.segmentation import slic
from skimage.measure import regionprops
from my_geom import *

def encode(filename, seg_ratio, greyscale):
  img = imread(filename)

  height = len(img)
  width = len(img[0])
  ratio = width/height

  if greyscale:
    raster_size = 558
    raster_ratio = 11
    num_segs = 94
    set1_len = 70
    max_num = 8928  # 558 * 16
  else:
    raster_size = 402
    raster_ratio = 13
    num_segs = 70
    set1_len = 56
    max_num = 86832 # 402 * 216

  raster_width = (raster_size*ratio)**0.5
  raster_height = int(raster_width/ratio)
  raster_width = int(raster_width)

  resize_height = raster_height * raster_ratio
  resize_width = raster_width * raster_ratio

  img = resize(img, (resize_height, resize_width))

  segs = slic(img, n_segments=num_segs-4, ratio=seg_ratio).astype('int16')

  max_label = segs.max()
  numpy.place(segs, segs==0, [max_label+1])
  regions = [None]*(max_label+2)

  for props in regionprops(segs):
    label = props['Label']
    props['Greyscale'] = greyscale
    regions[label] = Region(props)

  for i, a in enumerate(regions):
    for j, b in enumerate(regions):
      if a==None or b==None or a==b: continue
      if a.centroid == b.centroid:
        numpy.place(segs, segs==j, [i])
        regions[j] = None

  for y in range(resize_height):
    for x in range(resize_width):
      label = segs[y][x]
      regions[label].add_point(img[y][x])

  regions = [r for r in regions if r != None]

  if len(regions)>num_segs:
    regions = sorted(regions, key=lambda r: r.area)[-num_segs:]

  regions = sorted(regions, key=lambda r: r.to_num(raster_width))

  set1, set2 = regions[-set1_len:], regions[:-set1_len]

  set2_num = 0
  for s in set2:
    set2_num *= max_num
    set2_num += s.to_num(raster_width)

  set2_num = ((set2_num*85 + raster_width)*85 + raster_height)*25 + len(set2)
  perm = num2perm(set2_num, set1_len)
  set1 = permute(set1, perm)

  outnum = 0
  for r in set1:
    outnum *= max_num
    outnum += r.to_num(raster_width)

  outnum *= 2
  outnum += greyscale

  outstr = ''
  for i in range(140):
    outstr = chr(32 + outnum%95) + outstr
    outnum //= 95

  print outstr

parser = argparse.ArgumentParser(description='Encodes an image into a tweetable format.')
parser.add_argument('filename', type=str,
  help='The filename of the image to encode.')
parser.add_argument('--ratio', dest='seg_ratio', type=float, default=30,
  help='The segmentation ratio. Higher values (50+) will result in more regular shapes, lower values in more regular region color.')
parser.add_argument('--greyscale', dest='greyscale', action='store_true',
  help='Encode the image as greyscale.')
args = parser.parse_args()

encode(args.filename, args.seg_ratio, args.greyscale)

decoder.py
from __future__ import division
import argparse
from PIL import Image, ImageDraw, ImageChops, ImageFilter
from my_geom import *

def decode(instr, no_blending=False):
  innum = 0
  for c in instr:
    innum *= 95
    innum += ord(c) - 32

  greyscale = innum%2
  innum //= 2

  if greyscale:
    max_num = 8928
    set1_len = 70
    image_mode = 'L'
    default_color = 0
    raster_ratio = 11
  else:
    max_num = 86832
    set1_len = 56
    image_mode = 'RGB'
    default_color = (0, 0, 0)
    raster_ratio = 13

  nums = []
  for i in range(set1_len):
    nums = [innum%max_num] + nums
    innum //= max_num

  set2_num = perm2num(nums)

  set2_len = set2_num%25
  set2_num //= 25

  raster_height = set2_num%85
  set2_num //= 85
  raster_width = set2_num%85
  set2_num //= 85

  resize_width = raster_width*raster_ratio
  resize_height = raster_height*raster_ratio

  for i in range(set2_len):
    nums += set2_num%max_num,
    set2_num //= max_num

  regions = []
  for num in nums:
    r = Region()
    r.from_num(num, raster_width, greyscale)
    regions += r,

  masks = []

  outimage = Image.new(image_mode, (resize_width, resize_height), default_color)

  for a in regions:
    mask = Image.new('L', (resize_width, resize_height), 255)
    for b in regions:
      if a==b: continue
      submask = Image.new('L', (resize_width, resize_height), 0)
      poly = a.centroid.bisected_poly(b.centroid, resize_width, resize_height)
      ImageDraw.Draw(submask).polygon(poly, fill=255, outline=255)
      mask = ImageChops.multiply(mask, submask)
    outimage.paste(a.avg_color, mask=mask)

  if not no_blending:
    outimage = outimage.resize((raster_width, raster_height), Image.ANTIALIAS)
    outimage = outimage.resize((resize_width, resize_height), Image.BICUBIC)
    smooth = ImageFilter.Kernel((3,3),(1,2,1,2,4,2,1,2,1))
    for i in range(20):outimage = outimage.filter(smooth)
  outimage.show()

parser = argparse.ArgumentParser(description='Decodes a tweet into and image.')
parser.add_argument('--no-blending', dest='no_blending', action='store_true',
    help="Do not blend the borders in the final image.")
args = parser.parse_args()

instr = raw_input()
decode(instr, args.no_blending)

my_geom.py
from __future__ import division

class Point:
  def __init__(self, x, y):
    self.x = x
    self.y = y
    self.xy = (x, y)

  def __eq__(self, other):
    return self.x == other.x and self.y == other.y

  def __lt__(self, other):
    return self.y < other.y or (self.y == other.y and self.x < other.x)

  def inv_slope(self, other):
    return (other.x - self.x)/(self.y - other.y)

  def midpoint(self, other):
    return Point((self.x + other.x)/2, (self.y + other.y)/2)

  def dist2(self, other):
    dx = self.x - other.x
    dy = self.y - other.y
    return dx*dx + dy*dy

  def bisected_poly(self, other, resize_width, resize_height):
    midpoint = self.midpoint(other)
    points = []
    if self.y == other.y:
      points += (midpoint.x, 0), (midpoint.x, resize_height)
      if self.x < midpoint.x:
        points += (0, resize_height), (0, 0)
      else:
        points += (resize_width, resize_height), (resize_width, 0)
      return points
    elif self.x == other.x:
      points += (0, midpoint.y), (resize_width, midpoint.y)
      if self.y < midpoint.y:
        points += (resize_width, 0), (0, 0)
      else:
        points += (resize_width, resize_height), (0, resize_height)
      return points
    slope = self.inv_slope(other)
    y_intercept = midpoint.y - slope*midpoint.x
    if self.y > midpoint.y:
      points += ((resize_height - y_intercept)/slope, resize_height),
      if slope < 0:
        points += (resize_width, slope*resize_width + y_intercept), (resize_width, resize_height)
      else:
        points += (0, y_intercept), (0, resize_height)
    else:
      points += (-y_intercept/slope, 0),
      if slope < 0:
        points += (0, y_intercept), (0, 0)
      else:
        points += (resize_width, slope*resize_width + y_intercept), (resize_width, 0)
    return points

class Region:
  def __init__(self, props={}):
    if props:
      self.greyscale = props['Greyscale']
      self.area = props['Area']
      cy, cx = props['Centroid']
      if self.greyscale:
        self.centroid = Point(int(cx/11)*11+5, int(cy/11)*11+5)
      else:
        self.centroid = Point(int(cx/13)*13+6, int(cy/13)*13+6)
    self.num_pixels = 0
    self.r_total = 0
    self.g_total = 0
    self.b_total = 0

  def __lt__(self, other):
    return self.centroid < other.centroid

  def add_point(self, rgb):
    r, g, b = rgb
    self.r_total += r
    self.g_total += g
    self.b_total += b
    self.num_pixels += 1
    if self.greyscale:
      self.avg_color = int((3.2*self.r_total + 10.7*self.g_total + 1.1*self.b_total)/self.num_pixels + 0.5)*17
    else:
      self.avg_color = (
        int(5*self.r_total/self.num_pixels + 0.5)*51,
        int(5*self.g_total/self.num_pixels + 0.5)*51,
        int(5*self.b_total/self.num_pixels + 0.5)*51)

  def to_num(self, raster_width):
    if self.greyscale:
      raster_x = int((self.centroid.x - 5)/11)
      raster_y = int((self.centroid.y - 5)/11)
      return (raster_y*raster_width + raster_x)*16 + self.avg_color//17
    else:
      r, g, b = self.avg_color
      r //= 51
      g //= 51
      b //= 51
      raster_x = int((self.centroid.x - 6)/13)
      raster_y = int((self.centroid.y - 6)/13)
      return (raster_y*raster_width + raster_x)*216 + r*36 + g*6 + b

  def from_num(self, num, raster_width, greyscale):
    self.greyscale = greyscale
    if greyscale:
      self.avg_color = num%16*17
      num //= 16
      raster_x, raster_y = num%raster_width, num//raster_width
      self.centroid = Point(raster_x*11 + 5, raster_y*11+5)
    else:
      rgb = num%216
      r, g, b = rgb//36, rgb//6%6, rgb%6
      self.avg_color = (r*51, g*51, b*51)
      num //= 216
      raster_x, raster_y = num%raster_width, num//raster_width
      self.centroid = Point(raster_x*13 + 6, raster_y*13 + 6)

def perm2num(perm):
  num = 0
  size = len(perm)
  for i in range(size):
    num *= size-i
    for j in range(i, size): num += perm[j]<perm[i]
  return num

def num2perm(num, size):
  perm = [0]*size
  for i in range(size-1, -1, -1):
    perm[i] = int(num%(size-i))
    num //= size-i
    for j in range(i+1, size): perm[j] += perm[j] >= perm[i]
  return perm

def permute(arr, perm):
  size = len(arr)
  out = [0] * size
  for i in range(size):
    val = perm[i]
    out[i] = arr[val]
  return out

That's nothing short of amazing

The color version of the Mona Lisa looks like one of her boobs popped. Jesting aside, this is incredible.

Using the permutations to encode additional data is rather clever.

Really really awesome. Can you make a gist with this 3 files? https://gist.github.com/

Is this compression lossless?

@rubik it is incredibly lossy, as are all of the solutions to this challenge ;)

@primo: Ah, I was guessing so!

PHP
OK, took me a while, but here it is. All images in greyscale. Colors took too many bits to encode for my method :P

Mona Lisa
47 Colors Monochrome
101 byte string.
dt99vvv9t8G22+2eZbbf55v3+fAH9X+AD/0BAF6gIOX5QRy7xX8em9/UBAEVXKiiqKqqqiqqqqNqqqivtXqqMAFVUBVVVVVVVVVVU

2D Shapes
36 Colors Monochrome
105 byte string.
oAAAAAAABMIDUAAEBAyoAAAAAgAwAAAAADYBtsAAAJIDbYAAAAA22AGwAAAAAGwAAAAAAAAAAKgAAAAAqgAAAACoAAAAAAAAAAAAAAAAA

Hindenburg
62 Colors Monochrome
112 characters.
t///tCSuvv/99tmwBI3/21U5gCW/+2bdDMxLf+r6VsaHb/tt7TAodv+NhtbFVX/bGD1IVq/4MAHbKq/4AABbVX/AQAFN1f8BCBFntb/6ttYdWnfg

Mountains
63 Colors Monochrome
122 characters.
qAE3VTkaIAKgqSFigAKoABgQEqAABuAgUQAGenRIBoUh2eqhABCee/2qSSAQntt/s2kJCQbf/bbaJgbWebzqsPZ7bZttwABTc3VAUFDbKqqpzY5uqpudnp5vZg

My Method
I encode my bitstream with a type of base64 encoding. Before it's encoded into readable text, here's what happens.
I load the source image and resize it to a maximum height or width (depending on orientation, portrait/landscape) of 20 pixels.
Next I recolor each pixel of the new image to it's closest match on a 6 color greyscale palette.
After that's done, I create a string with each pixel color represented by the letters [A-F].
I then calculate the distribution of the 6 different letters within the string and select the most optimized binary tree for encoding based on the letter frequencies. There are 15 possible binary trees.
I start my bit stream with a single bit, [1|0] depending on whether the image is tall or wide. I then use the next 4 bits in the stream to inform the decoder which binary tree should be used to decode the image.
What follows is the stream of bits representing the image. Each pixel and it's color is represented by either 2 or 3 bits. This allows me to store at least 2 and up to 3 pixels worth of information for every printed ascii character. Here's a sample of binary tree 1110, which is used by the Mona Lisa:
    TREE
   /    \
  #      #
 / \    / \
E   #  F   #
   / \    / \
  A   B  C   D

The letters E 00 and F 10 are the most common colors in the Mona Lisa. A 010, B 011, C 110, and D 111 are the least frequent.
Binary trees work like this: Going from bit to bit, 0 means go left, 1 means go right. Keep going until you hit a leaf on the tree, or a dead end. The leaf you end up on is the character you want.
Anyways, I encode the binary sting into base64 characters. When decoding the string, the process is done in reverse, assigning all the pixels to the appropriate color, and then the image is scaled twice the encoded size (maximum 40 pixels either X or Y, whichever is larger) and then a convolution matrix is applied to the whole thing to smooth out the colors.
Anyways, here's the current code: "pastebin link"
It's ugly, but if you see any room for improvements, let me know. I hacked it together as I want along. I LEARNED A LOT FROM THIS CHALLENGE. Thank you OP for posting it!

These look incredibly good considering how much unutilized storage space you have (Mona Lisa uses only 606 bits from 920 available!).

Thank you, primo, I truly appreciate that. I always admire your work, so hearing you say that is quite flattering!

My first attempt. This has room for improvement. I think that the format itself actually works, the issue is in the encoder. That, and I'm missing individual bits from my output... my (slightly higher quality then here) file ended up at 144 characters, when there should have been some left. (and I really wish there was - the differences between these and those are noticeable). I learnt though, never overestimate how big 140 characters is...
I bring it down to a modified version of the RISC-OS palette - basically, because I needed a 32 colour palette, and that seemed like a good enough place to start. This could do with some changing too I think.

I break it down into the following shapes:

and split the image into palette blocks (in this case, 2x2 pixels) of a front and back color.
Results:
Following are the tweets, the originals and how the tweet is decoded
*=If`$aX:=|"&brQ(EPZwxu4H";|-^;lhJCfQ(W!TqWTai),Qbd7CCtmoc(-hXt]/l87HQyaYTEZp{eI`/CtkHjkFh,HJWw%5[d}VhHAWR(@;M's$VDz]17E@6

"&7tpnqK%D5kr^u9B]^3?`%;@siWp-L@1g3p^*kQ=5a0tBsA':C0"*QHVDc=Z='Gc[gOpVcOj;_%>.aeg+JL4j-u[a$WWD^)\tEQUhR]HVD5_-e`TobI@T0dv_el\H1<1xw[|D

)ey`ymlgre[rzzfi"K>#^=z_Wi|@FWbo#V5|@F)uiH?plkRS#-5:Yi-9)S3:#3 Pa4*lf TBd@zxa0g;li<O1XJ)YTT77T1Dg1?[w;X"U}YnQE(NAMQa2QhTMYh..>90DpnYd]?

%\MaaX/VJNZX=Tq,M>2"AwQVR{(Xe L!zb6(EnPuEzB}Nk:U+LAB_-K6pYlue"5*q>yDFw)gSC*&,dA98`]$2{&;)[ 4pkX |M _B4t`pFQT8P&{InEh>JHYn*+._[b^s754K_

I know the colours are wrong, but I actually like the Monalisa. If I removed the blur (which wouldn't be too hard), it's a reasonable cubist impression :p
I need to work on

Adding shape detection
A better colour "difference" algorithm
Figuring out where my missing bits went

I'll give it some more work later to try to fix those, and improved the encoder. Those extra 20 or so characters make a massive amount of difference. I'd like them back.
The C# source and colour palette are on https://dl.dropboxusercontent.com/u/46145976/Base96.zip - although, in hindsight, may not work perfectly when run separately (as spaces in arguments to programs don't go so well).
The encoder takes less then a couple of seconds on my fairly average machine.

Dude. Those look better than any contemporary art I've seen in a gallery... You should make huge prints of them and sell them!

It looks like I need to take the cartridge out of my Atari and plug it back in. I like it.

I gave up on trying to keep the colour and went black and white, since everything I tried with colour was unrecognisable.
Basically all it does is divide pixels into 3 approximately equal parts: black, grey and white.  It also doesn't keep the size.
Hindenburg
~62RW.\7`?a9}A.jvCedPW0t)]g/e4 |+D%n9t^t>wO><",C''!!Oh!HQq:WF>\uEG?E=Mkj|!u}TC{7C7xU:bb`We;3T/2:Zw90["$R25uh0732USbz>Q;q"

Mona Lisa
=lyZ(i>P/z8]Wmfu>] T55vZB:/>xMz#Jqs6U3z,)n|VJw<{Mu2D{!uyl)b7B6x&I"G0Y<wdD/K4hfrd62_8C\W7ArNi6R\Xz%f U[);YTZFliUEu{m%[gw10rNY_`ICNN?_IB/C&=T

Mountains
+L5#~i%X1aE?ugVCulSf*%-sgIg8hQ3j/df=xZv2v?'XoNdq=sb7e '=LWm\E$y?=:"#l7/P,H__W/v]@pwH#jI?sx|n@h\L %y(|Ry.+CvlN $Kf`5W(01l2j/sdEjc)J;Peopo)HJ

Shapes
3A"3yD4gpFtPeIImZ$g&2rsdQmj]}gEQM;e.ckbVtKE(U$r?{,S>tW5JzQZDzoTy^mc+bUV vTUG8GXs{HX'wYR[Af{1gKwY|BD]V1Z'J+76^H<K3Db>Ni/D}][n#uwll[s'c:bR56:

Here's the program.  python compress.py -c img.png compresses img.png and prints the tweet.
python compress.py -d img.png takes the tweet from stdin and saves the image to img.png.
from PIL import Image
import sys
quanta  = 3
width   = 24
height  = 24

def compress(img):
    pix = img.load()
    psums = [0]*(256*3)
    for x in range(width):
        for y in range(height):
            r,g,b,a = pix[x,y]
            psums[r+g+b] += 1
    s = 0
    for i in range(256*3):
        s = psums[i] = psums[i]+s

    i = 0
    for x in range(width):
        for y in range(height):
            r,g,b,a = pix[x,y]
            t = psums[r+g+b]*quanta / (width*height)
            if t == quanta:
                t -= 1
            i *= quanta
            i += t
    s = []
    while i:
        s += chr(i%95 + 32)
        i /= 95
    return ''.join(s)

def decompress(s):
    i = 0
    for c in s[::-1]:
        i *= 95
        i += ord(c) - 32
    img = Image.new('RGB',(width,height))
    pix = img.load()
    for x in range(width)[::-1]:
        for y in range(height)[::-1]:
            t = i % quanta
            i /= quanta
            t *= 255/(quanta-1)
            pix[x,y] = (t,t,t)
    return img

if sys.argv[1] == '-c':
    img = Image.open(sys.argv[2]).resize((width,height))
    print compress(img)
elif sys.argv[1] == '-d':
    img = decompress(raw_input())
    img.resize((256,256)).save(sys.argv[2],'PNG')

Lol, +1 for non-constrained aspect ratios.

My modest contribution in R:
encoder<-function(img_file){
    img0 <- as.raster(png::readPNG(img_file))
    d0 <- dim(img0)
    r <- d0[1]/d0[2]
    f <- floor(sqrt(140/r))
    d1 <- c(floor(f*r),f)
    dx <- floor(d0[2]/d1[2])
    dy <- floor(d0[1]/d1[1])
    img1 <- matrix("",ncol=d1[2],nrow=d1[1])
    x<-seq(1,d0[1],by=dy)
    y<-seq(1,d0[2],by=dx)
    for(i in seq_len(d1[1])){
        for (j in seq_len(d1[2])){
            img1[i,j]<-names(which.max(table(img0[x[i]:(x[i]+dy-1),y[j]:(y[j]+dx-1)])))
            }
        }
    img2 <- as.vector(img1)
    table1 <- array(sapply(seq(0,255,length=4),function(x)sapply(seq(0,255,length=4),function(y)sapply(seq(0,255,length=4),function(z)rgb(x/255,y/255,z/255)))),dim=c(4,4,4))
    table2 <- array(strsplit(rawToChar(as.raw(48:(48+63))),"")[[1]],dim=c(4,4,4))
    table3 <- cbind(1:95,sapply(32:126,function(x)rawToChar(as.raw(x))))
    a <- as.array(cut(colorspace::hex2RGB(img2)@coords,breaks=seq(0,1,length=5),include.lowest=TRUE))
    dim(a) <- c(length(img2),3)
    img3 <- apply(a,1,function(x)paste("#",c("00","55","AA","FF")[x[1]],c("00","55","AA","FF")[x[2]],c("00","55","AA","FF")[x[3]],sep=""))
    res<-paste(sapply(img3,function(x)table2[table1==x]),sep="",collapse="")
    paste(table3[table3[,1]==d1[1],2],table3[table3[,1]==d1[2],2],res,collapse="",sep="")
    }

decoder<-function(string){
    s <- unlist(strsplit(string,""))
    table1 <- array(sapply(seq(0,255,length=4),function(x)sapply(seq(0,255,length=4),function(y)sapply(seq(0,255,length=4),function(z)rgb(x/255,y/255,z/255)))),dim=c(4,4,4))
    table2 <- array(strsplit(rawToChar(as.raw(48:(48+63))),"")[[1]],dim=c(4,4,4))
    table3 <- cbind(1:95,sapply(32:126,function(x)rawToChar(as.raw(x))))
    nr<-as.integer(table3[table3[,2]==s[1],1])
    nc<-as.integer(table3[table3[,2]==s[2],1])
    img <- sapply(s[3:length(s)],function(x){table1[table2==x]})
    png(w=nc,h=nr,u="in",res=100)
    par(mar=rep(0,4))
    plot(c(1,nr),c(1,nc),type="n",axes=F,xaxs="i",yaxs="i")
    rasterImage(as.raster(matrix(img,nr,nc)),1,1,nr,nc)
    dev.off()
    }

The idea is simply to reduce the raster (file has to be in png) to a matrix whose number of cell is lower than 140, the tweets is then a serie of colors (in 64 colors) preceded by two characters indicated the number of rows and columns  of the raster.
encoder("Mona_Lisa.png")
[1] ",(XXX000@000000XYi@000000000TXi0000000000TX0000m000h00T0hT@hm000000T000000000000XX00000000000XXi0000000000TXX0000000000"

encoder("630x418.png") # Not a huge success for this one :)
[1] "(-00000000000000000000EEZZooo00E0ZZooo00Z00Zooo00Zo0oooooEZ0EEZoooooooEZo0oooooo000ooZ0Eo0000oooE0EE00oooEEEE0000000E00000000000"

encoder("2d shapes.png")
[1] "(,ooooooooooooooooooooo``ooooo0o``oooooooooo33ooooooo33oo0ooooooooooo>>oooo0oooooooo0ooooooooooooolloooo9oolooooooooooo"

encoder("mountains.png")
[1] "(,_K_K0005:_KKK0005:__OJJ006:_oKKK00O:;;_K[[4OD;;Kooo4_DOKK_o^D_4KKKJ_o5o4KK__oo4_0;K___o5JDo____o5Y0____440444040400D4"

Not a complete solution, just putting the method out there. (Matlab)
I used a 16 color palette and 40 position to create a weighted voronoi diagram. Used genetic algorithm and simple hill-climbing algorithm to fit the image.
Album with original image and I also have a 16 byte version with 4 colors and fixed positions there. :)

(Can I resize image here?)

Can you post the other images? I wanna see what they look like with this compression!

@jdstankosky Sorry, I can't do it now. Maybe some time later...

C#
Update - Version 2

I made another attempt at this, now using MagickImage.NET(https://magick.codeplex.com/) to encode the JPEG data, I also wrote some basic code to better process JPEG header data(as primo suggested), I also used GuassianBlur on the output which help soften some of the JPEG compression. As the new version preforms better, I've updated my post to reflect the new method.

Method

I've tried something unique(hopefully), rather than trying to manipulate the color depth, or edge identification, or trying to use different ways to reduce the images size myself I've used the JPEG algorithm at maximum compression on scaled down versions of the images, then by eliminating everything but the "StartOfScan"(http://en.wikipedia.org/wiki/JPEG#Syntax_and_structure) and a few key header elements I'm able to get the size down to a acceptable amount. The results are actually pretty impressive for 140 characters, gives me a new found respect for JPEG's:
Hindenburg

,$`"(b $!   _ &4j6k3Qg2ns2"::4]*;12T|4z*4n*4<T~a4- ZT_%-.13`YZT;??e#=*!Q033*5>z?1Ur;?2i2^j&r4TTuZe2444b*:>z7.:2m-*.z?|*-Pq|*,^Qs<m&?:e--

Mountains

,$  (a`,!  (1 Q$ /P!U%%%,0b*2nr4 %)3t4 +3#UsZf3S2 7-+m1Yqis k2U'm/#"h q2T4#$s.]/)%1T &*,4Ze w$Q2Xqm&: %Q28qiqm Q,48Xq12 _

Mona Lisa

23  (a`,!  (1 Q$ /P q1Q2Tc$q0,$9--/!p Ze&:6`#*,Tj6l0qT%(:!m!%(84|TVk0(*2k24P)!e(U,q2x84|Tj*8a1a-%** $r4_--Xr&)12Tj8a2Tj* %r444 %%%% !

Shapes

(ep 1# ,!  (1 Q$ /P"2`#=WTp $X[4 &[Vp p<T +0 cP* 0W=["jY5cZ9(4 (<]t  ]Z %ZT -P!18=V+UZ4" #% i6%r}#"l p QP>*r $!Yq(!]2 jo* zp!0 4 % !0 4 % '!

Code

Version 2 - http://pastebin.com/Tgr8XZUQ
I'm really starting to miss ReSharper + I have allot of things to improve, still allot of hard coding going on here, interesting to mess with though(remember you need MagickImage dll's to get this to run in VS)

Original(Deprecated) - http://pastebin.com/BDPT0BKT
Still bit of a mess.

"This is really a mess right now," I'll agree with that - surely there must be a better way to generate that header? But I suppose results are what matter most. +1

Python 3
Method
What the program does first is scaling down the image, greatly decreasing its size.
Second, it converts the rgb values into binary, and snips off the last few digits.
Then it converts the base 2 data into base 10, where it adds the dimensions of the picture.
Then it converts the data in base 10 to base 95, using all the ascii I could find. However, I could not use /x01 and the like because of its ability to negate the function that wrote out the text file.
And (for added ambiguity), the decode function does it in reverse.
compress.py
    from PIL import Image
def FromBase(digits, b): #converts to base 10 from base b
    numerals='''0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_-+={[}]|:;"',<.>/?`~\\ '''
    D=[]
    for d in range(0,len(digits)):
        D.append(numerals.index(digits[d]))
    s=0
    D=D[::-1]
    for x in range(0,len(D)):
        s+=D[x]*(b**x)
    return(str(s))
def ToBase(digits,b): #converts from base 10 to base b
    numerals='''0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_-+={[}]|:;"',<.>/?`~\\ '''
    d=int(digits)
    D=''
    B=b
    while(B<=d):
        B*=b
    B//=b
    while(B>=1):
        D+=numerals[d//B]
        d-=((d//B)*B)
        B//=b
    return(D)
im=Image.open('1.png')
size=im.size
scale_factor=40
im=im.resize((int(size[0]/scale_factor),int(size[1]/scale_factor)), Image.ANTIALIAS)
a=list(im.getdata())
K=''
for x in a:
    for y in range(0,3):
        Y=bin(x[y])[2:]
        while(len(Y))<9:
            Y='0'+Y
        K+=str(Y)[:-5]
K='1'+K
print(len(K))
K=FromBase(K,2)
K+=str(size[0])
K+=str(size[1])
K=ToBase(K,95)
with open('1.txt', 'w') as outfile:
    outfile.write(K)

decode.py
    from random import randint, uniform
from PIL import Image, ImageFilter
import math
import json
def FromBase(digits, b): #str converts to base 10 from base b
    numerals='''0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_-+={[}]|:;"',<.>/?`~\\ \x01\x02\x03\x04\x05\x06\x07'''
    D=[]
    for d in range(0,len(digits)):
        D.append(numerals.index(digits[d]))
    s=0
    D=D[::-1]
    for x in range(0,len(D)):
        s+=D[x]*(b**x)
    return(str(s))
def ToBase(digits,b): #str converts from base 10 to base b
    numerals='''0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_-+={[}]|:;"',<.>/?`~\\ \x01\x02\x03\x04\x05\x06\x07'''
    d=int(digits)
    D=''
    B=b
    while(B<=d):
        B*=b
    B//=b
    while(B>=1):
        D+=numerals[d//B]
        d-=((d//B)*B)
        B//=b
    return(D)
scale_factor=40
K=open('1.txt', 'r').read()
K=FromBase(K,95)
size=[int(K[-6:][:-3])//scale_factor,int(K[-6:][-3:])//scale_factor]
K=K[:-6]
K=ToBase(K,2)
K=K[1:]
a=[]
bsize=4
for x in range(0,len(K),bsize*3):
    Y=''
    for y in range(0,bsize*3):
        Y+=K[x+y]
    y=[int(Y[0:bsize]+'0'*(9-bsize)),int(Y[bsize:bsize*2]+'0'*(9-bsize)),int(Y[bsize*2:bsize*3]+'0'*(9-bsize))]
    y[0]=int(FromBase(str(y[0]),2))
    y[1]=int(FromBase(str(y[1]),2))
    y[2]=int(FromBase(str(y[2]),2))
    a.append(tuple(y))
im=Image.new('RGB',size,'black')
im.putdata(a[:size[0]*size[1]])
im=im.resize((int(size[0]*scale_factor),int(size[1]*scale_factor)), Image.ANTIALIAS)
im.save('pic.png')

The Scream

hqgyXKInZo9-|A20A*53ljh[WFUYu\;eaf_&Y}V/@10zPkh5]6K!Ur:BDl'T/ZU+`xA4'\}z|8@AY/5<cw /8hQq[dR1S 2B~aC|4Ax"d,nX`!_Yyk8mv6Oo$+k>_L2HNN.#baA

Mona Lisa

f4*_!/J7L?,Nd\#q$[f}Z;'NB[vW%H<%#rL_v4l_K_ >gyLMKf; q9]T8r51it$/e~J{ul+9<*nX0!8-eJVB86gh|:4lsCumY4^y,c%e(e3>sv(.y>S8Ve.tu<v}Ww=AOLrWuQ)

Spheres

})|VF/h2i\(D?Vgl4LF^0+zt$d}<M7E5pTA+=Hr}{VxNs m7Y~\NLc3Q"-<|;sSPyvB[?-B6~/ZHaveyH%|%xGi[Vd*SPJ>9)MKDOsz#zNS4$v?qM'XVe6z\

authors: Tʀᴀᴠɪꜱ Wᴏᴏᴅʙᴜʀʏ

authors: l๑OⱹɨᏐᎿã ïllüsträtïön


text:
Reverse words without changing capitals or punctuation
Create a program with the lowest amount of characters to reverse each word in a string while keeping the order of the words, as well as punctuation and capital letters, in their initial place.
By "Order of the words," I mean that each word is split by a empty space (" "), so contractions and such will be treated as one word. The apostrophe in contractions should stay in the same place. ("Don't" => "Tno'd").
(Punctuation means any characters that are not a-z, A-Z or whitespace*).

Numbers were removed from this list due to the fact that you cannot have capital numbers. Numbers are now treated as punctuation.

For example, for the input:
Hello, I am a fish.

it should output:
Olleh, I ma a hsif.

Notice that O, which is the first letter in the first word, is now capital, since H was capital before in the same location.
The comma and the period are also in the same place.
More examples:
This; Is Some Text!

would output
Siht; Si Emos Txet!

Any language can be used. The program with the lowest amount of characters wins.

How should contractions be treated? That is does Don't touch that! map to t'noD hcuot taht! or to noD't hcuot taht!?

@dmckee "(Punctuation means any characters that are not a-z, A-Z, 1-9 or whitespace)"

@dmckee so it should map to Nod't hcuot tath!

Reversing each word is easy. Reversing each word and keeping capitalisation is not.

Yup, that's the challenge ;) just simply reversing them would be too simple and would likely come down to the language used. This is meant to make you think.

I've added clarification on contractions, as well as spaces/words, in the second paragraph.

Now, after the edit, it's getting much more interesting :-o

What case should be letters that replace a digit? Should S'm00ch1e become E'1hc00ms or E'1HC00Ms? I suggest treating digits as punctuation: E'h00cm1s

That is a good point; would it be bad if I changed the question now to treat digits as punctuation now, after the question has been up for a while?

I don't think it would be bad

I wouldn't call it changing a question

Okay, well, I've changed the question to include that. Thanks for pointing it out.

Perhaps "as well as punctuation and capital letters" would read better "as well as punctuation and positions where letters are capitalized".

Whitespace is kept in place and thus treated as punctuation. Thus "Punctuation means any characters that are not a-z, A-Z or whitespace*" should read "Punctuation means any characters that are not in a-z or A-Z."

@DavidCarraher, Whitespace characters are still special as they separate words, otherwise “Don't touch it!” would become “tih'c uottn oD!”. If you want to rephrase that way, you have to add that “punctuations are kept in place relative to the word, whitespaces are kept in place relative to the string”.

What about numbers 0-9? are they reversed or kept as is?

@nasonfish Just reversing would be too broad to remain open?

@ΈρικΚωνσταντόπουλος Just reversing, without having to pay attention to punctuation/spaces, doesn't seem like a good problem to golf; many languages have something like string.reverse() which could solve the whole problem for them without much effort or room for improvement. The goal was to have a problem that's a bit of a challenge to do in the first place - reversing some characters while keeping others still - and then more of a challenge to condense.

GolfScript, 58 54 48 characters
" "/{.{65- 223&26<}:A,\{.A{96&\)31&@+}*}%+}%" "*

This is a GolfScript solution which became rather long. Lots of the code is actually finding out if a character is in a-zA-Z. Maybe someone can find an even shorter way of testing it.
You can try the code online. Examples:
> Hello, I am fish.
Olleh, I ma hsif.

> This; Is Some Text!
Siht; Si Emos Txet!

> Don't try this at home.
Tno'd yrt siht ta emoh.

That online golfscript editor looks useful. Bookmarking, thanks

You can pull the final " " inside the % to save one. I've found other ways of testing a-zA-Z for 11 chars, but none yet for 10.

Coffeescript, 134 133 characters
alert prompt().replace /\S+/g,(x)->c=x.match r=/[a-z]/gi;return x.replace r,(y)->return c.pop()[`(y<"a"?"toUpp":"toLow")`+"erCase"]()

Coffeescript is (for the purposes of code golf) a slightly denser version of javascript. It doesn't have the ternary operator, but it has an escape to javascript.
Here's the javascript version:
Javascript, 152 151 characters
alert(prompt().replace(/\S+/g,function(x){c=x.match(r=/[a-z]/gi);return x.replace(r,function(y){return c.pop()[(y<"a"?"toUpp":"toLow")+"erCase"]()})}))

Indented:
alert(prompt().replace(/\S+/g,function(x){
  c=x.match(r=/[a-z]/gi);
  return x.replace(r, function(y){
    return c.pop()[(y<"a"?"toUpp":"toLow")+"erCase"]()
  })
}))

APL 69
Takes screen input via: t←⍞
⎕av[1↓∊(↑¨v),¨((¯1×⌽¨z)+z←¯32×~1↓¨v>97)+¨⌽¨1↓¨v←(+\v<66)⊂v←0,⎕av⍳t←⍞]

Shouldn't APL be counted in UTF-8 bytes? :-)

@JanDvorak The APL+Win V5 character set is single byte. I have to convert to UTF-8 to post here in order for the characters to render correctly. ⎕av⍳t above returns an index into the character set from 0-255 for the characters in the vector t.

Ruby: 89 characters (including 1 for the -p switch)
Not copied Jan Dvorak's CoffeeScript solution, but after many attempts my code ended looking like an exact copy. A subconscious voice probably kept whispering “follow the white rabbit Jan Dvorak”. So upvotes for the algorithm should go to his answer.
$_.gsub!(/\S+/){|m|l=m.scan r=/[a-z]/i;m.gsub(r){|c|l.pop.send c<?a?:upcase: :downcase}}

Sample run:
bash-4.2$ ruby -p reverse-word.rb <<< "Hello, I am a fish.
This; Is Some Text!
Don't touch that!
S'm00ch1e"
Olleh, I ma a hsif.
Siht; Si Emos Txet!
Tno'd hcuot taht!
E'h00cm1s

Lua, 143
print(((io.read"*l"):gsub("%w+",function(s)local r=""for i=1,#s do r=("")[s:byte(-i)>96 and"lower"or"upper"](s:sub(i,i))..r end return r end)))

Nice try, but it should also keep punctuation in place: http://pastebin.com/X8QLf6fW

EDIT: oh i see now

EcmaScript 6 (112 characters)
The input is provided in s.
alert(s.replace(/\S+/g,x=>(_=x.match(X=/[a-z]/gi),x.replace(X,a=>_.pop()[(a<"a"?"toUpp":"toLow")+"erCase"]()))))

Based on @Jan Dorvak's answer.

C# (375)
 public static string rev(string s)
    {
        var r = new Regex("[^A-za-z]");

        var result = "";
        var token = "";
        foreach (var c in s)
        {
            if (!r.IsMatch(c + ""))
            {
                token += c;
            }
            else
            {
                result += new string(token.Reverse().ToArray());
                result += c;
                token = "";
            }
        }

        var arr = result.ToArray();
        int i = 0;
        foreach (var c in s)
        {
            arr[i] = char.IsUpper(c) ? char.ToUpper(arr[i]) : char.ToLower(arr[i]);
            i++;
        }

        result = new string(arr);
        return result;
    }

Minified
public static string rev(string s){var r=new Regex("[^A-za-z]");var result="";var token="";foreach(var c in s){if(!r.IsMatch(c+"")){token+=c;}else{result+=new string(token.Reverse().ToArray());result+=c;token="";}}var arr=result.ToArray();int i=0;foreach(var c in s){arr[i]=char.IsUpper(c)?char.ToUpper(arr[i]):char.ToLower(arr[i]);i++;}result=new string(arr);return result;}

Shouldn't it be A-Za-z?

@Cyoce A little detail: [A-z] is not [A-Za-z]. The first one is a common (?) mistake, 'cause it contains non-alphabetic characters.

Also shouldn't this be, erm, golfed?

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Write the shortest text getter/setter on an element for the DOM
Just like jQuery's $.fn.text, write one or two functions that can get and set the text on an element.
You can't use textContent or innerText, and even less innerHTML.
Plain javascript. No DOM library. It has to work on major browsers. (No need to care about old IE.)
Shortest code wins.
Enjoy!

is function name going to be counted towards the total?

Yep. I should be able to put your function in my page and use it right away. But it should be the same limitation for everyone, so it's not like it's unfair to anyone.

So, one letter function names. Got it.

@Shmiddty Also, not having the function declaration would be unfair to people wanting to use recursion.

JavaScript (167)
function t(e,h,f){if(h||h==''){while(f=e.lastChild)e.removeChild(f);e.appendChild(document.createTextNode(h))}h=e.data||'';for(c in f=e.childNodes)h+=t(f[c]);return h}

Usage :
var textContent = t(yourElement); // get the text content
t(yourElement, ''); // clear
t(yourElement, newText); // sets a new text

Note that there is no pollution of the global namespace
Demonstration, with a multi-level DOM tree and a few tests

if('split' in h)

@Shmiddty That would force the function user to pass something not undefined.

The code golf SE counter reports 175 characters, not 218. Why is it so?

@JanDvorak where's this counter ? It's my first time here...

@dystroy http://stackapps.com/questions/2048/code-golf-userscript-enhancement-pack

There's a formatting problem : if you edit my answer you see a bigger code...

Hint that other people can use: data is shorter than nodeValue :-). Can you post the non-golfed version too?

Well... As I have no makefile to golf it, I don't have any non-golfed version anymore. But I'll write it properly with 20 chars variable names as soon as I decide to stop shrinking it.

JavaScript (175)
function t(e,v,f){if(!v&&v!=''){v=e.data||'';for(c in f=e.childNodes)v+=t(f[c]);return v}else{ while(c=e.lastChild)e.removeChild(c);e.appendChild(document.createTextNode(v))}}

I have significantly less morality than @dystroy, so I didn't bother with var. I did have to scope f though, and I did it somewhat cleverly.
That said, our answers are pretty similar, and I'm not sure there's much of a better way to go about it.
With collection recognition (173):
function t(e,v){if(!v&&v!=''){v=e.data||'';for each(c in e.childNodes)v+=t(c);return v}else{ while(c=e.lastChild)e.removeChild(c);e.appendChild(document.createTextNode(v))}}

JavaScript (V8), 143 bytes
t=(e,h)=>h?.sub?[...e.children].map(c=>e.removeChild(c))&&e.appendChild(document.createTextNode(h)):(e.data||'')+[...e.childNodes].map(c=>t(c))

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Shortest code to determine if a string is a palindrome
A palindrome is some string that is spelled the same way both backwards and forwards.  For instance, 'Eva, can I stab bats in a cave?' is a palindrome (EVACANISTAB | BATSINACAVE)
For this code golf, using the language of your choice, determine if a given string is a palindrome or not.
Edge Cases:

Punctuation is not counted towards palindrominess.
Control characters are not counted towards palindrominess.
Whitespace is not counted towards palindrominess.
Numbers are counted towards palindrominess.
Case in this challenge is not counted towards palindrominess.
There is no limit to the length of strings to evaluate, except for what is imposed by your language of choice.
For this challenge, limit yourself to the ASCII character set.

Technical Requirements:

Only method bodies are needed; additional things like method signatures, data structure declarations, etc. do not count towards the victory requirement.
Code must compile or interpret without compile-time errors or exceptions.
Code must not throw any unhandled exceptions or crash.  (Almost needless to say.  Almost.)
Code must return some value indicating palindrominess.  The data type depends on the language you use (e.g. a C# user might use a bool, whereas a JavaScript user could use a var.)
You may not write your own interpreter that performs this task as a 'native' capability so you can 'golf' a near-winning score.  (Hopefully needless to say.)

Victory Condition:

The shortest code in characters wins.

Current Leader: tmartin (k, 25 characters)
...Want the magic green check mark by your answer?  Beat this guy's answer!

Is I/O a part of the challenge, or a function body will do?

What about case? Non-ASCII and control characters?

@PeterTaylor based on the example, case should be ignored. I assume control characters are punctuation.

Updated with clarifications per comments.

The "breadcrumbs" for showing how the work is refined are available site-wide in all answers via revision history. There's no need to have a full history visible in the current version of the answer.

Could you clarify Code must not throw any unhandled exceptions or crash. please? Should there be no exceptions for any input or any valid input?

No exceptional states for any input; the edge case descriptions should ensure that the given code is immune to any gotchas (emphasis on should.)

2 hours for code golf? Some alternatives seem shorter in the few hours since... That's a mite quick, or am I missing something?

@WernerCD I'm sure the OP will change who gets the green tick when he comes back to check on the new responses.

Not specifying a language really trivialises this challenge for me. As seen below, interpreted languages with a focus on high order text manipulation functions always get the shortest results.
What is to stop me throwing together my own interpreter with a single function, ip(). My compete algorithm is now 'ip:i'. 4 characters. done.

@Gusdor see J and GolfScript suck all the enjoyment out of Code Golf and Language Handicap and related questions on this site's meta.

Gareth: You're right, I do.
Gusdor: I would think 'no custom language' is an implicit rule.  Of course, you bring up a fair point.
WernerCD: I do keep an eye on this, but I have to sleep (I am a mere mortal.)

I was under the impression that the green tick can't be changed after a set amount of time. Different between sites? My misunderstanding? If you can change the green tick to keep current with the leader, then I stand corrected :)

K, 25
{x~|x:_x@&x in,/.Q`a`A`n}

.
k){x~|x:_x@&x in,/.Q`a`A`n}"Eva, can I stab bats in a cave?"
1b

Looks like a mixture of Q and k :P

Well, I wouldn't exactly call .Q.A etc q. They're just string wrappers, there's no real k code underneath them. Now, if I said .q.inter I'd be in trouble.

I guess it's a case of quibbling over semantics but they are defined in q.k

Could just say Q for 31: {x~(|)x:(_)x inter(,/).Q\a`A`n}`

i know this is very old but... you can save 1 byte with {#|:\_x@&x in,/.Q`a`A`n} , where 1 is true and 2 is false

Perl, 26 char
s/_|\W//g;uc eq reverse uc

Evaluates to 1 when $_ is a palindrome, "" (one of Perl's false values) when it is not.
Sample usage:
sub palin {
    s/_|\W//g;uc eq reverse uc
}
while (<DATA>) {
    chomp;
    print "$_ => ",palin()?"yes":"no","\n";
}
__DATA__
Eva, can I stab bats in a cave?
A man, a plan, a canal. Panama!
Madam, I'm Adam Carolla.
757
Boeing 757
A man, a plan, a big shovel, a canal. Panama!
A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats, a peon, a canal >> __Panama__

output:
Eva, can I stab bats in a cave? => yes
A man, a plan, a canal. Panama! => yes
Madam, I'm Adam Carolla. => no
757 => yes
Boeing 757 => no
A man, a plan, a big shovel, a canal. Panama! => no
A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats, a peon, a canal >> __Panama__ => yes

Damn, you beat me to it. Though this won't work properly if there's a _ in the string will it? And it doesn't take any input so won't you need to use the -p option?

\W in regexes excludes underscore. I'm afraid you'll need [^a-z\d] in your regex. I'm afraid I'm beaten anyways.

Save one with _|\W instead of [_\W].

You can shorten _|\W to \Pl: http://ideone.com/0ufdaQ . Should be just the Unicode letters.

Actually, thinking again - \Pl would not match digits, so I guess _|\W is the best you could do.

C# 82 only :)
var x=s.ToLower().Where(char.IsLetterOrDigit);return x.SequenceEqual(x.Reverse());

Couldn't resist the temptation of writing a boilerplate-free program in my favorite language.
A test is available here: http://ideone.com/8bwz7z

Simple...but elegant!

@AndrewGray thank you for the comment and for the permissive Technical Requirements. C# boilerplate adds seriously to the char count, making it impractical for golf otherwise.

No prob.  I'm a fellow C# dev, and I like writing concise, efficient code.  It's a shame there's so much boilerplate in the language...

GolfScript, 36 34 31 30 characters
{0"0:A[a{"@{>^}+/},{32|}%.-1%=

Similar algorithm to my previous (Javascript) solution.
0"0:A[a{"@{>^}+/ -- Optimised by Peter Taylor and Howard. My version was "/9@Z"{1$<},,2%\;. Howard donated function concatenation and Peter Taylor donated XOR for modulo-2. It's basically a generic method of comparing if the value is in a sequence of ranges.
{.96>32*-}% (11 characters) is not really an improvement over Javascript's .toUpperCase() (14 characters), especially since it mangles some weird punctuation that follows z in the ASCII table (which doesn't matter here).
as Peter Taylor's suggested, however, if we filter out alphanumerics first, we can convert to lowercase and digits just by setting one bit in each character: {32|}
.-1%= does all the palindromic heavy lifting. One part I'm not really fond of is how long it took me to find out how to reverse an array. I should have read the docs. The other two characters perform stack management and comparison.
Test: http://golfscript.apphb.com/?c=IkV2YSwgY2FuIEkgc3RhYiBiYXRzIGluIGEgY2F2ZT8iCgp7IjA6QVtheyJcez59KywsMiV9LHszMnx9JS4tMSU9

Further, if I can assume that none of the following control characters are present: (Data link escape, device control 1-4, negative acknowledge, synchronous idle, end of transmission block, cancel, end of medium) (we all agree these are all pretty obscure) or if I can treat them as uppercase versions of the digits 0-9, we can save another two characters:
GolfScript, 28 characters
{32|}%{0"0:a{"@{>^}+/},.-1%=

Test: http://golfscript.apphb.com/?c=IkV2YSwgY2FuIEkgc3RhYiBiYXRzIGluIGEgY2F2ZT8iCgp7MzJ8fSV7MCIwOmF7IkB7Pl59Ky99LC4tMSU9

You can get rid of the clean up and save two chars: {"0:A["\{>}+,,2%},

@Howard Thanks. I think I misunderstood + on blocks. That's a cool trick.

You can save three chars by reversing the filter and the case standardisation. You have to add a{ to the filter's list of characters to include the lower-case letters, but you can then upper-case with just {32|}%. The end result is {"0:A[a{"\{>}+,,2%},{32|}%.-1%=

There also another saving to be made on the filter. Counting modulo 2 is xor, so 0"0:A[a{"@{>^}+/ does the job.

@PeterTaylor If I don't come up with another optimisation myself soon, I probably should convert to community wiki. Thanks again :-)

Javascript, 53 characters:
(x=x.toLowerCase().match(/[a-z\d]/g))+""==x.reverse()

is a javascript expression that evaluates to true if x is a palindrome, to false if it isn't. It assumes x is a string. If that's not guaranteed, prepend x+="",
Here's a breadcrumb: Due to how reverse() works,
(x=x.toLowerCase().match(/[a-z\d]/g))==""+x.reverse()

fails. However,
""+(x=x.toLowerCase().match(/[a-z\d]/g))==x.reverse()

is perfectly fine.

Nice tidbit on concatenating a null string!  Points for good infoz!

Hints: +"" casts to a string, + casts to a number, |0 and ~~ cast to an integer, !! casts to a boolean.

Is a char shorter with regex /[^\W_]/g

Python 2: 49 (without counting the method signature)
def f(s):
 s=filter(str.isalnum,s.upper())
 return s==s[::-1]

A complete program, with input and output can be writte in 74 characters.
import sys
s=filter(str.isalnum,sys.stdin.read().upper())
print s==s[::-1]

Example usage:
$echo 'Eva,can I stab bats in a cave?' | python palindrome.py
True
$ cat huge_palindrome.txt | python palindrome.py
True
$echo 'Able was I ere i SaW elBa' | python palindrome.py
True

(huge_palindrome.txt contains this 17,826 word palindrome)
This solution can be adapted to python 3 adding some characters:
Python 3: 55
def f(s):
 s=list(filter(str.isalnum,s.upper()))
 return s==s[::-1]

sys.stdin.read is basically the same as raw_input

In Python 3.8 you can shorten this to 58 bytes

Also, your Python 2 & 3 solution is 61 bytes and 67 bytes, respectively.

@MilkyWay90 You probably missed the without counting the method signature. In 2013 it was customary to not include it. In other solution in this question in other languages they simply omitted it and assumed you have the input in an s variable. I decided to provide the complete definition but, as customary in 2013, do not include the method signature in the length

@Bakuriu Ah, I see. I've only been here a few months, so I don't know customs from 2013

@Bakuriu So then my solution would be an alternative solution for 49 bytes (not counting the method singature)

Bash: 52 48 46 characters
s=${1,,};s=${s//[^a-z0-9]};[ $s = `rev<<<$s` ]

This takes the sting to check as first parameter and sets the exit code to 0 for palindrome and 1 for not.
Sample run:
bash-4.2$ p() { s=${1,,};s=${s//[^a-z0-9]};[ $s = `rev<<<$s` ]; }

bash-4.2$ p 'Eva, can I stab bats in a cave?'; echo $?
0

bash-4.2$ p 'A man, a plan, a canal. Panama!'; echo $?
0

bash-4.2$ p "Madam, I'm Adam Corolla."; echo $?
1

bash-4.2$ p '757'; echo $?
0

bash-4.2$ p 'Boeing 757'; echo $?
1

bash-4.2$ p 'A man, a plan, a shovel, a canal. Panama!'; echo $?
1

bash-4.2$ p 'A_man,_a_plan, a_caremer, a canal:_Panama!'; echo $?
0

Mathematica 54 53
One byte saved thanks to CatsAreFluffy:
PalindromeQ@StringCases[ToUpperCase@#,WordCharacter]&

For those with version 10.2 or earlier:
#==Reverse@#&@StringCases[ToUpperCase@#,WordCharacter]&

Example
PalindromeQ@StringCases[ToUpperCase@#, WordCharacter]&["Eva,can I stab bats in a cave?"]

True

PalindromeQ is 1 byte shorter than #==Reverse@#&

I wondered why I had never seen it. Version 10.3!

PalindromeQ= #==Reverse@#&

Yes, I downloaded v. 10.4 to try it out.

That's out? OHNO

JAVA (or the most verbose language ever), 102 96 95 char
s=s.replaceAll("\\W|_","");return s.equalsIgnoreCase(new StringBuffer(s).reverse().toString());

Usage (with ungolfed code):
static boolean q(String s) {
    s=s.replaceAll("\\W|_","");
    return s.equalsIgnoreCase(new StringBuffer(s).reverse().toString());
}

public static void main(String[] args) {
    System.out.println(q("'A man, a plan, a canal - Panama!'"));
}

Shortened with the help of the commenter below

While I don't know Java (I'm a C# guy, funny enough), couldn't you save 1 character by taking out the curly braces on the if?  E.G.: if(s==null) return 1==0;?  Or does Java enforce curlies on if statements?

You are absolutely right, I took that out thank you!!... I haven't notice they were there, I guess I'm a Java developer that doesn't C#?

Checking whether the parameter is null is a good habit, but not practiced in CodeGolf. As I can tell, nobody else did it in this question. Skip it. 2) The space between arguments helps readability, but not golfing. Remove it; 3) Instead of explicitly toLowerCase() the string use equalsIgnoreCase() later instead of equals(). This way you have to adjust the regular expression, but still 1 character shorter. http://pastebin.com/s7H84faj

replaceAll("[^A-Za-z0-9]","") => replaceAll("\\W","")

Actually: replaceAll("\\W|_",""); to remove _ too => 95 characters

I know this has been answered more than three years ago, but you can golf two more things: .toString() can be +"", and you can make it a one-lined to save another byte like this: return(s=s.replaceAll("\\W|_","")).equalsIgnoreCase(new StringBuffer(s).reverse()+""); (86 bytes)

R: 66
w=grep("[a-z0-9]",strsplit(tolower(s),"")[[1]],v=T);all(w==rev(w))

Usage:
f=function(s){w=grep("[a-z0-9]",strsplit(tolower(s),"")[[1]],v=T);all(w==rev(w))}

f("Eva, can I stab bats in a cave?")
[1] TRUE

k (50 48 45 38 chars)
Suppresses all errors, returning a default of 0b (false).
{X~|X@:&(X:_:x)in 10h$(48+!10),97+!26}

Example:
k){X~|X@:&(X:_:x)in 10h$(48+!10),97+!26} "Eva, can I stab bats in a cave?"
1b

edit: shaved three more character by avoiding intermediate variable. H/T, CS. -7: No need to suppress errors.

interesting that at just 3 characters more, my code is much more readable :-)

An extra char slipped in, I have removed it.

J, 30 characters
*/(=|.)tolower(#~'[^_\W]'rxE])

Usage:
   */(=|.)tolower(#~'[^_\W]'rxE])'A man, a plan, a canal - Panama!'
1
   */(=|.)tolower(#~'[^_\W]'rxE])'Doc, note: I dissent. A fast never prevents a fatness. I diet on cod'
1

Ruby: 43 38 characters
s=s.upcase.tr'^A-Z0-9','';s==s.reverse

Sample run:
irb(main):001:0> p=->s{s=s.upcase.tr'^A-Z0-9','';s==s.reverse}
=> #<Proc:0x854592c@(irb):1 (lambda)>

irb(main):002:0> p['Eva, can I stab bats in a cave?']
=> true

irb(main):003:0> p['A man, a plan, a canal. Panama!']
=> true

irb(main):004:0> p["Madam, I'm Adam Corolla."]
=> false

irb(main):005:0> p['757']
=> true

irb(main):006:0> p['Boeing 757']
=> false

irb(main):007:0> p['A man, a plan, a shovel, a canal. Panama!']
=> false

irb(main):009:0> p['A_man,_a_plan, a_caremer, a canal:_Panama!']
=> true

You can even write s.tr!('^A-Za-z0-9','').upcase!.reverse==s

Man, how long I combined around the use of the ! methods! You keep amazing me @Howard with your tricks.

Small problem though, @Howard. tr and tr! seems to behave different when they have nothing to transliterate: http://pastebin.com/4YThW2qN That makes the p['757'] test to crash with “NoMethodError: undefined method `upcase!' for nil:NilClass” error.

Oops, sorry. Didn't think about that case.

can be shortened further: s=s.upcase.tr('^A-Z0-9','');s==s.reverse

Ouch! What a stupid miss. Thank you, @w0lf. Event better, this way the parenthesis are not necessary anymore.

My version is s=s.upcase.gsub /\W/,'';s==s.reverse which. is 3 chars shorter.

@ŁukaszNiemier, according to my counting, that is only 2 characters shorter. And if you make it to work correctly by excluding underscores from the comparison, s=s.upcase.gsub /\W|_/,'';s==s.reverse will be 0 characters shorter.

C++, 107 (miscounted), 100 (miscounted), 81
string s;for(int c:t)if(isalnum(c))s+=c|32;return s==string(s.rbegin(),s.rend());

Exploits ASCII bit patterns.
Relies on an evil using namespace std;.
Uses bitwise AND and OR instead of the logical operators.
Uses int because it's shorter than char or auto.
#include <string>
using namespace std;

bool IsPalindrome(const string & t) {
string s;for(int c:t)if(isalnum(c))s+=c|32;return s==string(s.rbegin(),s.rend());
}

#include <cassert>

int main() {
    assert(!IsPalindrome("gorilla"));  // simple failure
    assert( IsPalindrome("racecar"));  // simple success
    assert( IsPalindrome("Hannah"));   // case blind
    assert(!IsPalindrome("1999"));     // digit failure
    assert( IsPalindrome("2002"));     // digit success
    // Ignore spacing, punctuation, and case:
    assert( IsPalindrome(" \t09AZ/:@[`{za90"));  // boundaries
    assert( IsPalindrome("A man, a plan, a canal: Panama."));
    assert( IsPalindrome("Eva, can I stab bats in a cave?"));
    assert( IsPalindrome(""));  // empty string
    return 0;
}

Lua, 56
a=io.read"*l":lower():gsub("%W","")print(a:reverse()==a)

If %W is anything like \W in regex, it also excludes characters like underscore. This is unwanted.

i checked, %w doesn't include _ (%W obviously includes it, then)

Only function body is needed.  s=s:lower():gsub('%W','')return s:reverse()==s  46 chars

but what about function(s)

Python 3/2 59 chars:
def pld(i):
   p=[c for c in i.lower() if c.isalnum()]
   return(p == p[::-1])

Haskell, 43
Using the standard libraries Control.Monad, Control.Monad.Instances, and Data.Char:
ap(==)reverse.map toLower.filter isAlphaNum

I can't make this to work in ghci.
import Data.Char
import Control.Monad
ap(==)reverse.map toLower.filter isAlphaNum
neither does it with adding spaces or such, sorry I'm not too keen with Haskell :)

@SlimJim: Oops, you need Control.Monad.Instances as well. (I’m using the Reader monad instance with ap, but that instance isn’t exported by Control.Monad.)

PHP 60 characters.
First try on codegolf.
//thank you manatwork
echo($x=preg_replace('/\W/','',strtolower($c)))==strrev($x);

Example:
$c='Eva, can I stab bats in a cave?';
echo($x=preg_replace('/\W/','',strtolower($c)))==strrev($x);
//prints 1

The parenthesis around the ternary operator's first operand are not needed. Actually neither the ternary operator is needed – just output true or false in your language's representation. And by avoiding the separate statement for the assignment to $x 1 more character can be shortened: echo($x=preg_replace('/\W/','',strtolower($c)))==strrev($x);.

Python 2 64 Charecters:
i =''.join(re.findall('[a-z0-9]+',i.lower()))
return i==i[::-1]

@manatwork If you replace all the identifiers with one character identifiers you obtain a 77 characters version. No idea why abhiram posted the ungolfed version though.

@Bakuriu, never mind, I missed one statement in the question: “Only method bodies are needed”. Though lines 2 and 3 gives me only 73 characters. Regarding further length reduction, no need for raw string and the capture group, making the re.findall('[a-z0-9]+',input.lower()) part 3 characters shorter.

@manatwork, I edited the post and changed the variables a little. That brought it down to 66.
Yes, the raw string attribute is of no use here.

Ok, but why you insist on the capturing group in the regular expression? Works correctly without: http://pastebin.com/JzpNRRZU

I think it caught on with me after my recent python project involving re's :)
Thanks for pointing it out.

Haskell 48
(\x->x==reverse x).map toLower.filter isAlphaNum

used like this:
(\x->x==reverse x).map toLower.filter isAlphaNum$"Eva, can I stab bats in a cave?"

Smalltalk, Squeak/Pharo flavour
116 chars using traditional formatting with tabs
You add two methods to String:
selffles
    ^self = self reverse
isPalindrome
    ^(self asUppercase asDecomposedUnicode select: #isAlphaNumeric) selffles

We could of course eliminate some spaces, or use shorter method names, but let's not betray the spirit of Smalltalk.
More over, this will handle French palindromes, like in http://fr.wikipedia.org/wiki/Liste_de_palindromes_fran%C3%A7ais, not many answers in this page can.
['Léon a trop par rapport à Noël' isPalindrome] assert.

Clever and useful answer!

Python 3 (51 char)
and may be Python 2
based on abhiram solution (with more agressive golfing)
from re import findall

def palindrome(i):
 i=findall('[a-z\d]',i.lower())
 return i==i[::-1]

print(palindrome(input('Phrase: ')))

may be shortened to 46 chars, using RE '\w'
and variant with extremely shortened function body (27 chars)
import re
l=str.lower
f=re.compile('[a-z\d]').findall

def palindrome(i):i=f(l(i));return i==i[::-1]

print(palindrome(input('Phrase: ')))

Julia 1.0, 63 bytes
~s=((x=filter(in(['0':'9';'A':'Z']),uppercase(s)))==reverse(x))

Try it online!
Since punctuation is filtered out, "5,000 0.005" is considered a palindrome.

Windows PowerShell, 56 47 45 chars
Updated (see comments), and can remove the brackets around the regex:
($s=$s-replace'\W')-eq(-join$s[$s.length..0])

Original (56)
$s=$s-replace'[^\w]','';$s-eq($s[-1..-$s.length]-join'')

Original Un-golfed:
$s = "Eva, can I stab bats in a cave?"
$s = $s -replace '[^\w]', ''
$rev = $s[-1..-$s.length] -join ''
$s -eq $rev

You can golf this down to 47 chars like this: ($s=$s-replace'[\W]')-eq(-join$s[$s.length..0])

@SpellingD: Nice! I'm new at code golfing, thanks for the improvement

you can remove the right parenthesis also: ($s=$s-replace'\W')-eq-join$s[$s.length..0].

C++, 74 bytes
This code is actually really elegant, and easy to understand (when formatted correctly). I don't believe it's possible to get any shorter in C++, and it doesn't use any standard library functions.
p(auto c){auto e=c;while(*e)++e;--e;while(*e==*c&e>c)--e,++c;return e<=c;}

Example usage:
p("Hello"); //Outputs 0
p(""); //Outputs 1
p("a"); //Outputs 1
p("HellolleH"); //Outputs 1

Nicely formatted version:
p(auto c)
{
    auto e=c;
    while(*e) ++e;
    --e;
    while(*e==*c & e>c)--e,++c;
    return e<=c;
}

error: ISO C++ forbids declaration of ‘p’ with no type your function should have a return type.

I bet this does not ignore case, whitespace and control characters.

You can save a character with while(*++e); instead of while(*e)++e;. But as Titus mentioned this answer is invalid.

PHP, 26 84 80 78 62 63 bytes
<?=strrev($s=strtolower(preg_replace("#\W#","",$argv[1])))==$s;

takes input from first command line argument; prints 1 for truthy, empty string for falsy.

I18n is a littly expansive, as there is no multibyte alternative for strrev (110 bytes; run with -r):
preg_match_all("#.#us",$s=strtolower(preg_replace("#\W#u","",$argv[1])),$m);echo$s==join(array_reverse($m[0]);

utf8_strrev blatantly stolen from the PHP manual. You might also want to take a look at this blog post.

Come on Titus... This fails the spec.

@Christoph Yeah I sometimes should fully read that. Fixed.

Hm -R would cause problems with line breaks in the string to test wouldn't it? From the spec " -R   Run PHP  for every input line". Moreover <?=strrev($s=strtolower(preg_replace("#\W#","",$argn)))==$s;would be shorter.

@Christoph Nice idea, but there is no $argn without -R.

$argv[1]="O Genie, der Herr ehre dein Ego!"; # :D

K (ngn/k), 18 bytes
#|:\(2!"0:a{"')__:

Try it online!
Uses @scrawl's suggestion here to return 1 for palindromes and 2 for non-palindromes. If 1 and 0 are required, the solution can be adjusted by prefixing 1=.

_: lowercase the (implicit) input
(...)_ filter out values where the code in (...) returns a non-0 value

2!"0:a{"' do a bins lookup, then mod the result by two; returns 0 if the input is within "a"-"z" or "0"-"9" and 1 otherwise

|:\ set up a converge-scan, reversing the input until the original input is returned. on palindromes, returns a one-item list; on non-palindromes, a two-item list
# take the count of the result from above. As noted, if a strict 1 and 0 output are required for palindrome/non-palindrome, prefix 1= for two bytes

Ruby, 48
p((g=gets.upcase.gsub /[^A-Z\d]/,'')==g.reverse)

Quite simple, and hastily made so not golfed too much. I shall golf it more later.

Pylongolf2, 24 bytes
c╨2"[^a-zA-Z]"-_╨1=~

c takes the input, ╨2 to convert to lower case.
I then push a regex onto the stack and use - to remove all non-alphabetical characters in the input.
_ duplicates the input.
╨1 reverses it and = then compares them.
~ prints the stack in the end which prints either true or false.

Does this ignore the punctuation, whitespace and control characters?

My bad, this version does not.
I will fix it.

Fixed the problem.

Jelly, 10 Characters
fØBŒl
UÇ⁼Ç

Returns 1 if true, 0 if false
Try it Online!

Does it ignore case, whitespace and control characters? A breakdown would be nice.

The current state of Jelly allows for solving this in 7 bytes: fØBŒlŒḂ: f filter to keep ØB the set [a-zA-Z0-9] and Œl convert to lowercase, then ŒḂ test if palindrome.

Racket, 132 bytes
Pretty embarrassing, but maybe somebody can see a way of making this shorter!
((λ(l[n(floor(/(length l)2))])(equal?(take l n)(take(reverse l)n)))(string->list(regexp-replace*"[^0-9a-z]"(string-downcase s)"")))

Code listing with test module
#lang racket

(define/contract (palindrome? s)
  (string? . -> . boolean?)
  ((λ(l[n(floor(/(length l)2))])(equal?(take l n)(take(reverse l)n)))(string->list(regexp-replace*"[^0-9a-z]"(string-downcase s)""))))

(module+ test
  (require rackunit)
  (define tests
    '(("Eva, can I stab bats in a cave?" . #t)
      ("A man, a plan, a canal. Panama!" . #t)
      ("Madam, I'm Adam Corolla." . #f)
      ("757" . #t)
      ("Boeing 757" . #f)
      ("A man, a plan, a big shovel, a canal. Panama!" . #f)
      ("A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats, a peon, a canal >> __Panama__" . #t)))
  (for ([t tests])
    (check-equal? (palindrome? (car t)) (cdr t) (~a t))))

05AB1E, 4 bytes
álÂQ

Explanation:
á     # Only keep the alphabetic characters.
 l    # Lowercase the characters.
  Â   # Bifurcate, which duplicates the letters and reverses the duplicate.
   Q  # Check if they are equal.

Uses the CP-1252 encoding. Try it online!.

Tried to run it via your link. Program output is "1"

PowerShell, 194 190 bytes
A recursive implementation to show how an unnamed PowerShell scriptblock can call itself.
$P={param([string]$s)$s=($s-replace'[^a-z]').tolower();if(!$s){return $true};if($s.length-lt4){return $s[0]-eq$s[-1]};$s[0]-eq$s[-1]-and(&$MyInvocation.MyCommand.ScriptBlock $s.trim($s[0]))}

ungolfed:
$P={
param([string]$s)
$s=($s-replace'[^a-z]').tolower();
if(!$s){return $true};
if($s.length-lt4){return $s[0]-eq$s[-1]};
$s[0]-eq$s[-1]-and(&$MyInvocation.MyCommand.ScriptBlock $s.trim($s[0]))
}

tests:
&$P "Eva, can I stab bats in a cave?"
&$P "Eva, can I stab cats in a cave?"
&$P "A man, a plan, a canal. Panama!"
&$P "A man, a plan, a big shovel, a canal. Panama!"
&$P "Madam, I'm Adam."
&$P "Madam, I'm Adam Corolla."
&$P "757"
&$P "Boeing 757"

Shouldn´t that be [^a-z0-9]?

APL, 78 65 Bytes
l←⎕D,⎕UCS v+32⊣c←⎕D,⎕UCS v←64+⍳26⋄(⌽≡⊢)∊{⍵/⍨⍵∊l}¨{⍵∊c:l[c⍳⍵]⋄⍵}¨⎕

I'm going to assume that the Original Poster meant limit the INPUT string to the Ascii character set.

C++14, 104 bytes
Actually overlooked the requirement to ignore case and whitespace, so here is:
auto f=
[](auto s,int&n){
auto r=s.rbegin();n=1;for(auto c:s){if(isalnum(c)){while(!isalnum(*r))r++;if((c|32)!=(*(r++)|32))n=0;}}
}
;

strict solution, 72 68 bytes
-4 bytes for returning by parameter.
As unnamed lambda, assuming input s is of type std::string and returning the result by a parameter:
[](auto s,int&n){auto r=s.rbegin();n=1;for(auto c:s)if(c!=*r++)n=0;}

Ungolfed & usage:
#include <iostream>
#include <string>

auto f=
[](auto s, int& n){
  auto r=s.rbegin();
  n=1;
  for(auto c:s)
    if(c!=*r++)
      n=0;
}
;

int main(){
int n;
#define p(s) f(std::string(s),n); std::cout << n << std::endl
 p("Hello");
 p("ABCCBA");
 p("ABCBA");
}

Python 2.7.6, 79 bytes
"Sorry I don't get what characters to count so I wrote the whole program"
import re
n=raw_input()
n=re.sub("[^a-z]+","",n.lower())
print n==n[::-1]

This will print True if input string is palindrome else
False.

Code_link: http://ideone.com/b4NzLD

REXX, 84 bytes
arg n
n=space(translate(n,,translate(n,,xrange(a,z)xrange(0,9))),0)
say n=reverse(n)

arg n
reads argument into variable n, converting it to upper-case.
xrange(a,z)xrange(0,9) concatenates the two ranges A—Z and 0—9.
translate takes a string to process, an output translation table and an input translation table, and optionally a padding character to replace those characters not found in the output table with. Hence
translate(n,,xrange(a,z)xrange(0,9)) maps the string n with an input table consisting only of alphanumerical characters and an empty output table, resulting in a string consisting only of punctuation, spaces and other non-alphanumericals (since they were not in either table). The filtered-out characters are rendered as spaces.
translate(n,,translate(n,,xrange(a,z)xrange(0,9))) uses the above non-alphanumerics string as an input table and an empty output table, applying it to n, resulting in a string consisting only of alphanumericals, since they were not in the input or output tables. The non-alphanumerics are rendered as spaces.
space() takes a string and a number, spacing out the words with the supplied amount of spaces between. In this case, the supplied number is 0, hence all spaces are removed.
By this point, n has been reduced to consisting only of alphanumeric characters without any spaces.
say n=reverse(n) prints out whether n is identical to its reversed version.

Dyalog APL (18 characters)
 {⍵≡⌽⍵}'\w'⎕S'\u0'⊢

Search for alphanumeric characters in the right argument, and return any found upper-cased (this avoids any need for punctuation, whitespace and casing). Then just check what's returned to see if it matches the reverse.
Example
{⍵≡⌽⍵}'\w'⎕S'\u0'⊢'Eva, can I stab bats in a cave?'
    1

This is a snippet. The (tacit) function is {⍵≡⌽⍵}'\w'⎕S'\u0' which can be named (or parenthesised) before application. Also, you can save another byte by replacing {⍵≡⌽⍵} with (⊢≡⌽).

Vyxal, 6 bytes
kr↔⇩Ḃ=  #

kr      # push the upper and lowercase alphabet
  ↔⇩    # remove all chars in input that are not in that, and lowercase
    Ḃ   # push a and a.reverse()
     =  # equal?

Try it Online!

This ignores numbers in the input, so you need to replace kB with kr to make sure numbers get counted.

@AaronMiller Ah, I misread that as numbers are not counted, fixed

Thunno 2, 4 bytes
LỊḲ⁼

Try it online!
Explanation
LỊḲ⁼  # Implicit input
L     # Convert to lowercase
 Ị    # Only keep alphabetic characters
  Ḳ   # Duplicate and reverse
   ⁼  # Are they equal?
      # Implicit output

Swift, 82 77 bytes
let t=s.lowercased().replacing(/[\W_]/,with:"");return Array(t)==t.reversed()

Where s is a String argument. I think it's rather self-explanatory — that's the beauty of Swift.

Shaved off 5 bytes by using a regex and a call to replacing(_:with:).

JavaScript Code  :: ONLY  140 characters

      Palindrome

function palindrome()
{
    var user=prompt("Enter the characters to check the palindrome");
    var split=user.split('').reverse().join(''); // ONLY this line counts
    if(user == split)
    {
        alert("The given word is a Palindrome");
    } else
    {
        alert("The given word is not a Palindrome");
    }

}

palindrome();

Erm...afraid not, the comparison is also part of checking that a string is a palindrome.

oh... Sorry.. Then its takes 140 characters..

The requirement says you need to ignore uppercase vs. lowercase differences and punctuation.

Additionally, don't worry about the method signature.  We're just worried with how you solve the problem, not language-specific boilerplate.

Racket 118 bytes
(let((l(filter(λ(x)(or(char-alphabetic? x)(char-numeric? x)))(string->list(string-upcase s)))))(equal? l(reverse l)))

Ungolfed:
(define (palindrome? s)
  (let((l(filter(λ(x)(or(char-alphabetic? x)
                        (char-numeric? x)))
                (string->list (string-upcase s)))))
    (equal? l(reverse l))))

Testing:
(palindrome? "abc  dcB;_A")
(palindrome? "abc;@#$zdc b  a")
(palindrome? "1%^&234 56")
(palindrome? "1a234 * ^ && 565432A1")

Output:
#t
#f
#f
#t

This is neither case insensitive and nor does it ignore punctuation, control characters and whitespace.

Thanks for pointing out. I have corrected the code above.

AHK, 83 bytes (L7 loser)
StringUpper,s,1
s:=RegExReplace(s,"[\W_]")
Loop,Parse,s
t:=A_LoopField t
Send % s=t

Outputs 1 for palindromes and 0 for not.

C, 199 bytes
#define R return
#define C unsigned char
#define F for
s(C*a){C*b;if(a&&*a)F(b=a+strlen(a)-1;;++a,--b){F(;a<b&&!isalnum(*a);)++a;F(;a<b&&!isalnum(*b);)--b;if(a>=b)R 1;if((*a|32)-(*b|32))R 0;}R 1;}

//ungolf
v(C*a)
{ C*b;
 if(a&&*a)
   F(b=a+strlen(a)-1;;++a,--b)
           {F(;a<b&&!isalnum(*a);)++a;
            F(;a<b&&!isalnum(*b);)--b;
            if(a>=b)           R 1;
            if((*a|32)-(*b|32))R 0;
           }
 R 1;
}

#define P printf
main()
{C*b="Eva, can I stab bats in a cave?";
 P("%s %d\n", b, s(b));
 R 0;
}

//results
//Eva, can I stab bats in a cave? 1

Common Lisp, 72 65 bytes
(let((y(remove-if-not'alphanumericp(read))))(equalp(reverse y)y))

-7 bytes thanks to @ceilingcat !
Try it online!

Retina, 31 bytes
\W

T`l`L
+`^(.)(.*)\1$
$2
^.?$

Try it online!

QuadS, 19 bytes
Equivalent to James Heslip's solution.
⍵≡⌽⍵
\w
\u&

Try it online!
Is…
 ⍵≡⌽⍵ the text identical to its reverse
 \w after finding all word characters
 \u& and uppercasing them
?

C (gcc), 118 bytes
p(s,n)char*s,*n;{char*r=s+strlen(s)-1;for(*n=1;*s;s++)if(isalnum(*s)){for(;!isalnum(*r);r--);*n*=(*s|32)==(*r--|32);}}

Try it online!
Used like: p(string, &result);; outputs by modifying result.

Japt v2.0a0, 8 bytes
k\W v
¶Ô

Try it
k\W v\n¶Ô     :Implicit input of string U
k             :Remove
 \W           :  RegEx /[^a-z0-9/gi
    v         :Lowercase
     \n       :Reassign to U
       ¶      :Is equal to
        Ô     :Reverse

n=>n.split('').reverse().join('')==n;

Hi, welcome to Code Golf. This doesn't account for the fact that punctuation doesn't count towards palindrominess.

You are also missing the byte count in the header

Zsh, 42 bytes
s=${(L)1//[^A-Za-z0-9]}
<<<${s/`rev<<<$s`}

Try it online!
Truthy (palindrome) is empty string, falsy otherwise. TIO link includes a test harness that outputs T or F.