[Question]
  [
Code golf: Print an image of the source code.
**Requirements** 
1. Must output the image of the source code itself, not a version stored elsewhere and retrieved at run time.
2. Code must be legible enough to copy out by hand and reproduce the results.
Any image format is applicable.
**Bonuses**
* -10% of your score if you allow more than one output format.
* -15% if your code is *also* a 'true' quine. i.e. it does not read its source code but the source code is embedded (see [here](https://codegolf.stackexchange.com/a/23231/9534) for an example)
* -30% if your code is a strict quine - i.e the image of the code is embedded in the program (Piet solutions, I'm looking at you.).
  
[Answer]
# shell
By "Print an image of the source code", I assume that actually printing an image on paper would be acceptable.
```
#!/bin/sh
lpr $0
```
[Answer]
## Piet, 24399.76
![enter image description here](https://i.stack.imgur.com/XMLU8.gif)
[This was not made by me.](http://mamememo.blogspot.com/2009/10/piet-quine.html)
[Answer]
# PHP - 487 × 0.9 × 0.85 = 372.555 (2000×99px)
```
<?php $y="imagecolorallocate";$l=[
'<?php $y="imagecolorallocate";$l=[',
'];$i=imagecreate(2e3,99);$y($i,99,99,99);$w=$y($i,$j=0,0,0);$z=function($_)use(&$j,$i,$w){imagestring($i,4,9,$j+=15,$_,$w);};$z($l[0]);foreach($l as$m)$z(chr(39).$m.chr(39).",");$z($l[1]);$argv[1]($i,"o");',
];$i=imagecreate(2e3,99);$y($i,99,99,99);$w=$y($i,$j=0,0,0);$z=function($_)use(&$j,$i,$w){imagestring($i,4,9,$j+=15,$_,$w);};$z($l[0]);foreach($l as$m)$z(chr(39).$m.chr(39).",");$z($l[1]);$argv[1]($i,"o");
```
# If warnings are fine: PHP - 479 × 0.9 × 0.85 = 366.435
```
<?php $y=imagecolorallocate;$l=[
'<?php $y=imagecolorallocate;$l=[',
'];$i=imagecreate(2e3,99);$y($i,99,99,99);$w=$y($i,$j=0,0,0);$z=function($_)use(&$j,$i,$w){imagestring($i,4,9,$j+=15,$_,$w);};$z($l[0]);foreach($l as$m)$z(chr(39).$m.chr(39).",");$z($l[1]);$argv[1]($i,o);',
];$i=imagecreate(2e3,99);$y($i,99,99,99);$w=$y($i,$j=0,0,0);$z=function($_)use(&$j,$i,$w){imagestring($i,4,9,$j+=15,$_,$w);};$z($l[0]);foreach($l as$m)$z(chr(39).$m.chr(39).",");$z($l[1]);$argv[1]($i,o);
```
You provide the output function to use as the first command line argument:
```
php timwolla.php imagepng
```
Solution with warnings:
[![](https://i.stack.imgur.com/7tH6D.png)](https://i.stack.imgur.com/7tH6D.png)
[Answer]
**Whitespace, 125**
```
```
Outputs an image file in the [pbm](http://netpbm.sourceforge.net/doc/pbm.html) format.
If you're testing this code, please copy it by clicking on "Edit", and copying everything between the `<pre>` tags.
**Output:**
```
P1 1 1 0
```
[Answer]
# Mathematica, ~~37~~ 31 chars
```
(#2[#1[#0[#1,#2]]]&)[Defer,Rasterize]
```
```
(Rasterize[#1[#0[#1]]]&)[Defer]
```
![enter image description here](https://i.stack.imgur.com/EKq25.png)
Inspired by [an answer in mathematica.stackexchange.com](https://mathematica.stackexchange.com/questions/6104/mathematica-quine/6107#6107). 
[Answer]
## AppleScript, 68 37
Alright, if you can call ImageMagick in zsh then this too is valid. I'm still hacking at something more elegant and of-the-quine-spirit for my own satisfaction, but for pure golfiness, here we are:
**New version**
```
do shell script "screencapture q.jpg"
```
**Old version**
```
tell application "System Events" to keystroke "#" using command down
```
I imagine this will still be beaten, but verbose old AppleScript does an admirable imitation of succinctness for this one.
![stop your quine](https://i.stack.imgur.com/S8I2z.png)
```
do shell script "screencapture -c"
```
[Answer]
## Mathematica, 83
```
SelectionMove[InputNotebook[],Previous,Cell];Rasterize@NotebookRead@SelectedCells[]
```
![enter image description here](https://i.stack.imgur.com/nX099.png)
[Answer]
# Sh, X & ImageMagick 18.9:
```
 import -window root a.jpg
```
This should work in any shell that has ImageMagick.
To print only the code prepend `clear &&` this comes out at 26.1
```
clear && import -window root a.jpg
```
Sample output:
![enter image description here](https://i.stack.imgur.com/1vWOF.jpg)
[Answer]
**HTML5/Javascript : 615**
```
<canvas id='i' width=500 height=5000></canvas><script>function d(){var e=document.getElementById("i");var t=e.getContext("2d");t.font="20px Arial";var n=400;var r=25;var i=(e.width-n)/2;var s=60;str="<canvas id='i' width=5000 height=500></canvas>\n<script>"+d+"d();"+wrapText+"<\/script>";wrapText(t,str,i,s,n,r)}function wrapText(e,t,n,r,i,s){var o=t.split(" ");var u="";for(var a=0;a<o.length;a++){var f=u+o[a]+" ";var l=e.measureText(f);var c=l.width;if(c>i&&a>0){e.lineWidth=1;e.strokeStyle="blue";e.strokeText(u,n,r);u=o[a]+" ";r+=s}else{u=f}}e.lineWidth=1;e.strokeStyle="blue";e.strokeText(u,n,r)}d()</script>
```
Demo : <http://jsfiddle.net/E2738/2/>
One can right click on the image and save its as a PNG
[Answer]
# Java, 570 - 10% - 15% = 427.5
("filepath" included), 554 - 10% - 15% = 415.5 ("filepath" not included)  
Thanks to Andreas for removing `BufferedImage` in `java.awt.image.BufferedImage`
```
import java.awt.image.*;class Q{public static void main(String[]a)throws Exception{BufferedImage i=new BufferedImage(3500,12,1);String s="import java.awt.image.*;class Q{public static void main(String[]a)throws Exception{BufferedImage i=new BufferedImage(3500,12,1);String s=%s%s%s;char q=34;i.getGraphics().drawString(String.format(s,q,s,q,q,q,q,q),0,9);javax.imageio.ImageIO.write(i,%spng%s,new java.io.File(%sfilepath%s));}}";char q=34;i.getGraphics().drawString(String.format(s,q,s,q,q,q,q,q),0,9);javax.imageio.ImageIO.write(i,"png",new java.io.File("filepath"));}}
```
Output:![enter image description here](https://i.stack.imgur.com/RRSDw.png)
To view properly, see this link: <https://i.stack.imgur.com/RRSDw.png>
This works just like a regular quine, except it outputs to an image. The current format is `png`, but the format can easily be changed by replacing all instances of `png` in the program with whatever format you want.
Unlike a few answers here, this is a true quine; no reading of the program file.
[Answer]
## Javascript + JQuery 153 148
Regular
```
(function f(){
  c=$('<canvas/>')[0];
  a=c.getContext('2d');
  l=('('+f+')()').split('\n');
  for(i=0;i<l.length;i++)
    a.fillText(l[i],5,12*(i+1));
  $('body').append('<img src="'
      +c.toDataURL("image/png")+'"/>')
})()
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
```
Golfed
```
function f(){c=$('<canvas>')[0];c.width=750;a=c.getContext('2d');a.fillText(f+'f()',5,9);$('body').append('<img src="'+c.toDataURL("png")+'"/>')}f()
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
```
[Answer]
## zsh, 57 × 0.9 = 51.3
Pass it the output filename as an argument.
```
convert -annotate +0+10 "$(<$0)" -size 320x14 xc:white $1
```
Produces:
> 
> ![Example output](https://i.stack.imgur.com/MPBDA.png)
> 
> 
> 
[Answer]
## C99 (using SDL & SDL\_ttf), ~~414~~ ~~354~~ 346 - 15% = 294.1
```
#include<SDL_ttf.h>
#define Q(P)char*q=#P;P
Q(
i=5;main(){for(SDL_Surface*s=SDL_SetVideoMode(2048,80,SDL_Init(SDL_INIT_VIDEO),TTF_Init());i--;SDL_SaveBMP(s,"q.bmp"))SDL_BlitSurface(TTF_RenderText_Blended(TTF_OpenFont("q.ttf",9),(char*[]){"#include<SDL_ttf.h>","#define Q(P)char*q=#P;P","Q(",q,")"}[i],(SDL_Color){~0}),0,s,&(SDL_Rect){0,16*i});}
)
```
This is pretty ugly without more line breaks, but unfortunately they need to be absent. The text-rendering function doesn't grok control characters at all, so any line breaks in the code have to be rendered manually in the output.
Here's the same code but with some extra line breaks thrown in for legibility:
```
#include<SDL_ttf.h>
#define Q(P)char*q=#P;P
Q(
i=5;main(){for(SDL_Surface*s=SDL_SetVideoMode(2048,80,
SDL_Init(SDL_INIT_VIDEO),TTF_Init());i--;SDL_SaveBMP(s,"q.bmp"))
SDL_BlitSurface(TTF_RenderText_Blended(TTF_OpenFont("q.ttf",9),
(char*[]){"#include<SDL_ttf.h>","#define Q(P)char*q=#P;P","Q(",q,")"}[i],
(SDL_Color){~0}),0,s,&(SDL_Rect){0,16*i});}
)
```
Sadly, this doesn't also add line breaks to the graphical output:
![output](https://i.stack.imgur.com/jUS29.png)
The output is still legible, though with 9-point output and the red font color, it's a bit squinty. You can improve it at the cost of a character by replacing the `9` with `12`. (Note that the dimension of the resulting image is hardcoded to 2048x80. To accommodate the differences in various fonts, a fair bit of excess has been added to the right margin and the leading, enough so that a size-12 font should still fit comfortably. If you wish to increase it further, however, the dimensions will probably need to be altered as well.)
The command to build the program is:
```
gcc -Wall -o imgquine imgquine.c -lSDL_ttf `sdl-config --cflags --libs`
```
The program assumes that there is a font file called `q.ttf` in the current directory when run. I took care of this beforehand by running the following command (which should work on most modern Linuxes):
```
ln -s `fc-match --format='%{file}' sans` ./q.ttf
```
(Feel free to import your own favorite TrueType font instead.)
After running the program, the image output will be created in the current directory, in a file named `q.bmp`. Unfortunately Windows bitmap files are the only output format that this program provides. Adding more output formats would require linking in more libraries.
Note that this program takes advantage of C99's syntax for introducing non-simple literal values, thus significantly reducing the number of variables that need to be defined. This is something that more C golfers should take advantage of.
[Answer]
# C# - 498 - 15% = 423.3
This can probably be golfed more. I've never done quines or this kind of graphics in C# before:
```
using System;using System.Drawing;class Q{static void Main(){var b = new Bitmap(3050, 20);var g=Graphics.FromImage(b);string f="using System;using System.Drawing;class Q{{static void Main(){{var b = new Bitmap(3050, 20);var g=Graphics.FromImage(b);string f={0}{1}{0},e={3}{0}{2}{0};g.DrawString(String.Format(f,(char)34,f,e,'@'),SystemFonts.MenuFont,Brushes.Black,0,0);b.Save(e);}}}}",e=@"D:\p.png";g.DrawString(String.Format(f,(char)34,f,e,'@'),SystemFonts.MenuFont,Brushes.Black,0,0);b.Save(e);}}
```
Output:
![enter image description here](https://i.stack.imgur.com/lntKU.png)
Adding a different format support would be easy. Not sure if it's worth it, though.
[Answer]
## Ruby, 104 characters
```
require "RMagick"
include Magick
Draw.new.annotate(i=Image.new(999,99),0,0,0,9,File.read($0))
i.display
```
Example output, per request: [i.imgur.com/jMC594C.png](https://i.stack.imgur.com/M2Uvp.png)
[Answer]
# Python: ~~255~~ 238 -10% -15% = ~~195.075~~ 182.07
```
import sys,PIL.ImageDraw as D;i=D.Image.new('L',(2000,20));r="import sys,PIL.ImageDraw as D;i=D.Image.new('L',(2000,20));r=%r;D.Draw(i).text((0,0),r%%r,fill=255);i.save(sys.argv[1])";D.Draw(i).text((0,0),r%r,fill=255);i.save(sys.argv[1])
```
Usage:
```
python imgquine.py quine.jpg
```
This is a true quine that draws the output to the file specified on the commandline. The file format is set simply by changing the filename extension (e.g. `quine.jpg` for a JPEG and `quine.png` for a PNG).
Example output (2000x20 image):
![Quine output](https://i.stack.imgur.com/OanPR.png)
]