---
created_at: '2017-04-17T18:26:58.000Z'
title: MP3 for Image Compression (2006)
url: http://keyj.emphy.de/mp3-for-image-compression/
author: joshumax
points: 344
story_text: 
comment_text: 
num_comments: 96
story_id: 
story_title: 
story_url: 
parent_id: 
created_at_i: 1492453618
_tags:
- story
- author_joshumax
- story_14133221
objectID: '14133221'

---
[Source](http://keyj.emphy.de/mp3-for-image-compression/ "Permalink to KeyJ&#039;s Blog  : Blog Archive   &raquo; MP3 for image compression")

# KeyJ&#039;s Blog  : Blog Archive   &raquo; MP3 for image compression

KeyJ's Blog : Blog Archive » MP3 for image compression

Welcome to the website of

![KeyJ][1]

* * ## Pages

    * [About me][2]
    * [Projects][3]
        * [Demoscene][4]
        * [Tools & Scripts][5]
        * [Old Stuff][6]
        * [Studies][7]
* ## Archives

Archives Select Month September 2017  (1) April 2017  (1) May 2014  (1) November 2012  (1) May 2012  (1) February 2012  (1) September 2011  (1) June 2011  (1) February 2011  (1) January 2011  (1) June 2010  (1) April 2010  (1) February 2010  (1) January 2010  (2) December 2009  (1) September 2009  (1) August 2009  (2) April 2009  (3) February 2009  (4) January 2009  (3) December 2008  (2) August 2008  (1) June 2008  (2) April 2008  (1) December 2007  (2) October 2007  (1) September 2007  (2) August 2007  (2) July 2007  (1) May 2007  (1) April 2007  (2) March 2007  (1) February 2007  (3) January 2007  (4) December 2006  (1) October 2006  (3) September 2006  (3) August 2006  (1) July 2006  (2) June 2006  (3) May 2006  (3) April 2006  (7) March 2006  (6) February 2006  (10) January 2006  (5)
* ## Categories

    * [Computer Fun][8]
        * [Demoscene][9]
            * [Party Reports][10]
        * [Hacks][11]
            * [iPod][12]
    * [Other][13]
    * [Personal][14]
    * [Reviews][15]
* ## Tags

[4k][16] [Apple][17] [benchmark][18] [blog][19] [Breakpoint][20] [Demoscene][21] [Evoke][22] [games][23] [graphics][24] [H.264][25] [Impressive][26] [iPod][27] [JPEG][28] [Linux][29] [MPUI][30] [OpenGL][31] [rant][32] [rePear][33] [video][34] [Windows][35]

* ## Meta

    * [Log in][36]
    * ![RSS][37][ Entries][38]
    * ![RSS][37][ Comments][39]

# [MP3 for image compression][40]

(January 23, 2006)

During some random discussion with my colleague today, I rediscovered an experiment I did quite some years ago: MP3 compression of image data. This is, feed raw 8-bit-per-pixel grayscale image data into an MP3 encoder, let it compress it, and decode the MP3 file again. After some conversion (the decoder will always produce 16 bit signed output, but 8 bit unsigned image data is needed), a raw image file will result of this whole process, ready to be displayed with an arbitrary image viewer. Sounds simple, eh? :)  

I just reimplemented the whole thing, this time using some more-or-less standard Unix tools (bash, ImageMagick, LAME, Python) instead of Turbo Pascal and Paint Shop Pro handiwork. For the first test, I used some representative image, scaled it down to 960×720 pixels, and pretended that it was a 24 kHz mono sound file. The LAME encoder options were `-q 0 -k -b $SomeBitrate` (maximum quality, no lowpass filtering) with bitrates from 8 kbps on. The results are not as bad as the rude misuse of an audio-specific algorithm for image compression would suggest: Above 24 kbps (about 1 bit per pixel), quality is actually quite acceptable. Of course, it doesn’t even remotely match JPEG’s quality, there are still much artifacts that look a bit like noisy analogue TV reception.

By the way, the generated MP3 files sound a bit like recordings from space probes, so if you need some nifty sound effects, mp3img might be the right tool for you :)

## Files

* [mp3_vs_jpeg.png][41] (355k) – the MP3 vs. JPEG quality assessment
* [mp3img][42] (1k) – shell script to compress image files with MP3

_(This article is also available in Russian at [Softdroid][43])_

Posted in [Computer Fun][44], [Hacks][45] | [8 Comments ...][46]

# 8 Responses to »MP3 for image compression«

* MultimediaStudent (2014-02-25 23:25)

Cool!

* Espen (2017-04-17 21:33)

Nice. How about AAC and OGG? :)

* Toke Eskildsen (2017-04-17 22:15)

So I guess JPEG compression of a sound file is the next step?

* Matthew Fernandez (2017-04-18 05:06)

@Toke, why not go for ethernet-over-audio by pumping arbitrary data through the MP3 encoder, playing it, recording it on another machine, then trying to reverse that to what the MP3 encoder saw? Purpose unknown, but sounds challenging in a fun way.

* @Matthew (2017-04-18 09:55)

You’ve just invented dialup

* Liudas (2017-04-18 10:30)

Cool, so you’re now halfways visualizing sounds from space ;)

* [Miguel Luís][47] (2017-04-19 03:54)

Cool! I had a project in which the objective was sending images encoded as text. This comes in handy in remote areas where there’s only eg. GSM available. The challenge is in compression. ;)

* Tim (2017-05-02 08:15)

@Miguel, isn’t this just using something like PNG or JPEG compression to get a byte stream, then using something like Base64 to encode it as text? I would imagine this is doable in about 2 dozen lines of code (less if you don’t care about readability).

# Post a Reply

Name _(required)_

Mail (will not be published) _(required)_

Website

**XHTML:** You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

**Captcha:**  
Which number is greater: 5 or 4?  

[1]: http://keyj.emphy.de/wp-content/themes/keyj2/logo.png
[2]: https://keyj.emphy.de/about/
[3]: https://keyj.emphy.de/projects/
[4]: https://keyj.emphy.de/projects/demoscene/
[5]: https://keyj.emphy.de/projects/tools-scripts/
[6]: https://keyj.emphy.de/projects/old-stuff/
[7]: https://keyj.emphy.de/projects/studies/
[8]: https://keyj.emphy.de/category/computer-fun/ "Funny, interesting or absurd findings and hacks."
[9]: https://keyj.emphy.de/category/computer-fun/demoscene/ "Anything that has to do with the demoscene."
[10]: https://keyj.emphy.de/category/computer-fun/demoscene/party-reports/ "Reports from demoscene parties I've been attending."
[11]: https://keyj.emphy.de/category/computer-fun/hacks/ "Sometimes useless, sometimes useful, but always interesting software I wrote in my free time."
[12]: https://keyj.emphy.de/category/computer-fun/hacks/ipod/ "Anything that has to do with iPod hacking."
[13]: https://keyj.emphy.de/category/misc/ "Everything that doesn't fit into the other categories."
[14]: https://keyj.emphy.de/category/personal/ "Stuff that has to do with myself or with friends of mine."
[15]: https://keyj.emphy.de/category/reviews/ "Reviews of (or rants about) new technology (software or hardware), movies, or whatever is worth writing a review for :)"
[16]: https://keyj.emphy.de/tag/4k/ "5 topics"
[17]: https://keyj.emphy.de/tag/apple/ "5 topics"
[18]: https://keyj.emphy.de/tag/benchmark/ "4 topics"
[19]: https://keyj.emphy.de/tag/blog/ "9 topics"
[20]: https://keyj.emphy.de/tag/breakpoint/ "4 topics"
[21]: https://keyj.emphy.de/tag/demoscene/ "14 topics"
[22]: https://keyj.emphy.de/tag/evoke/ "4 topics"
[23]: https://keyj.emphy.de/tag/games/ "4 topics"
[24]: https://keyj.emphy.de/tag/graphics/ "5 topics"
[25]: https://keyj.emphy.de/tag/h264/ "6 topics"
[26]: https://keyj.emphy.de/tag/impressive/ "3 topics"
[27]: https://keyj.emphy.de/tag/ipod/ "8 topics"
[28]: https://keyj.emphy.de/tag/jpeg/ "4 topics"
[29]: https://keyj.emphy.de/tag/linux/ "7 topics"
[30]: https://keyj.emphy.de/tag/mpui/ "4 topics"
[31]: https://keyj.emphy.de/tag/opengl/ "4 topics"
[32]: https://keyj.emphy.de/tag/rant/ "14 topics"
[33]: https://keyj.emphy.de/tag/repear/ "3 topics"
[34]: https://keyj.emphy.de/tag/video/ "4 topics"
[35]: https://keyj.emphy.de/tag/windows/ "5 topics"
[36]: https://keyj.emphy.de/wp-login.php
[37]: http://keyj.emphy.de/wp-content/themes/keyj2/rss2.png
[38]: https://keyj.emphy.de/feed/ "Syndicate this site using RSS 2.0"
[39]: https://keyj.emphy.de/comments/feed/ "Syndicate this site using RSS 2.0"
[40]: https://keyj.emphy.de/mp3-for-image-compression/ "Permanent Link to MP3 for image compression"
[41]: http://keyj.emphy.de/files/mp3_vs_jpeg.png
[42]: http://keyj.emphy.de/files/mp3img
[43]: http://softdroid.net/mp3-dlya-szhatiya-izobrazheniya
[44]: https://keyj.emphy.de/category/computer-fun/
[45]: https://keyj.emphy.de/category/computer-fun/hacks/
[46]: https://keyj.emphy.de/mp3-for-image-compression/#comments
[47]: http://about.me/mluis

