Debian Codegraph @

tools/to-data-uri/README.md

raw symbols SCIP
1 # Convert any file to data URI scheme
2
3 This command-line application reads the data from file (given as command-line parameter) and outputs "data URI" for it.
4
5 ## What is "data URI"?
6
7 The "data URI" is a string you can use in [Castle Game Engine](https://castle-engine.io/), [X3D and VRML](https://castle-engine.io/vrml_x3d.php), HTML and CSS whenever they expect a URI.
8
9 For example, usually in X3D you specify a texture like this:
10
11 ```
12 texture ImageTexture { url "my_texture.png" } # relative URL
13 ```
14
15 or like this:
16
17 ```
18 texture ImageTexture { url "https://example.org/my_texture.png" } # absolute URL
19 ```
20
21 But thanks to _data URI scheme_, you can also specify the texture directly in the X3D file:
22
23 ```
24 texture ImageTexture { url "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQA..." }
25 ```
26
27 This application allows you to convert any file to such a data URI, visible in the last example as `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQA...`
28
29 It can be used to encode images, sounds, 3D models, whatever as data URI.
30
31 See http://en.wikipedia.org/wiki/Data_URI_scheme for description of data URIs.
32
33 ## Usage
34
35 Pass input file as a command-line parameter. The output is written to standard output. Example usage:
36
37 ```
38 to-data-uri my_texture.png > my_texture_data_uri.txt
39 ```
40
41 Command-line parameter is used with our [Download](https://castle-engine.io/apidoc/html/CastleDownload.html#Download-String-TStreamOptions-) routine. See [Networking in Castle Game Engine](https://castle-engine.io/manual_network.php) for more information about supported URLs.
42
43 So the given parameter may be:
44 - just a filename
45 - or an URL: a file URL, http URL (will be automatically downloaded) or even another data URI.
46
47 The _MIME type_ (necessary to output nice data URI) is also detected by our `Download` routine. For http, it may be returned by http server. For file, it's guessed based on file extension.