0

Is there any conventional way to turn an arbitrary string into an image?

In my use case, lets say I want to have an image for each user that maps directly to that user's name.

The concept is similar to QR codes, except the output image is not designed to be readable, simple pretty and consistent.

ultimately i want something like:

def to_image(a_string)
    ... #magic
    return a_data_uri
end

such that

# is always true
to_image("specific string") == to_image("specific string")

Ideally you'd end up with some nice looking fractal-art like image.

If what I'm describing is nonsensical, a function that can convert a string to a data-uri containing a qr code will do.

Hayk Saakian
  • 2,036
  • 2
  • 18
  • 31
  • Must the image be convertible back into the string? Have you looked at http://robohash.org/ ? – mydoghasworms Mar 15 '13 at 04:59
  • That's good, the only problem is that the site has really only 3 distinct sets, and put next to each other they're too similar. If there was something like that for fractals that'd be better. And no, I only need it one way. – Hayk Saakian Mar 15 '13 at 08:49

1 Answers1

0

One possibility would be to hash the strings - this gives you unique numbers as output. Then you can pass these numbers as input param to a fractal generating function.

For hashing either use a real hash function, or (in case the number of users is limited) you can use a CRC function (CRC16, CRC32). Both approaches will give you uniques numbers as output. For CRC you must be a little bit more careful - for instance having 60K input strings and using CRC16 might end up with some clashes (different strings - same CRC16 number).