<?xml version="1.0"?> 

<!--
	description:

		"Gobo Eiffel Image"

	tool: "Gobo Eiffel Image"
	copyright: "Copyright (c) 2020, Eric Bezault and others"
	license: "MIT License"
	date: "$Date$"
	revision: "$Revision$"
-->

<chapter xmlns="http://www.gobosoft.com/eiffel/gobo/documentation" id="geimage/implementation">
<chapterinfo>
	<copyright>
		<year>2020</year>
		<holder>Eric Bezault</holder>
	</copyright>
	<author>
		<firstname>Eric</firstname><surname>Bezault</surname>
	</author>
	<email>ericb@gobosoft.com</email>
	<date>17 May 2020</date>
</chapterinfo>

<title>Implementation of geimage</title>

<para>
A tool similar tool <projectname>geimage</projectname> is already available
in <projectname>ISE EiffelStudio</projectname>'s package. It is called
<projectname>Eiffel Image Embedder Tool</projectname> and is available
in <filename>$ISE_EIFFEL/tools/spec/$ISE_PLATFORM/bin/eimgemb</filename>.
Its documentation is <ulink url="https://www.eiffel.org/blog/larryliuming/eiffel_image_embedder_tool">here</ulink>.
<projectname>Geimage</projectname> differs from this tool in different ways.
</para>

<section><title>Size of resulting executable</title>
<para>
When embedding a png image whose file was 280 KB with
<projectname>eimgemb</projectname>, the executable size increased by 3 MB.
This is explained in the documentation of <projectname>eimgemb</projectname>:
the tool does not compress target image contents, so the size of the image
generated in executables is larger than original png file. But with tens
of such png files to be embedded in the executable, the resulting size
would have been impractical.
</para>
<para>
This is the primary reason why <projectname>geimage</projectname> has
been introduced. It embeds the image's bytes as-is,
keeping the compression of the original png file. As a result, the
size of the executable only increased by 300 KB, which is more
reasonable. Apart from that, the class text generated by <projectname>geimage</projectname>
looks pretty much the same as the one generated by <projectname>eimgemb</projectname>.
In particular, it only uses routines from <projectname>EiffelVision2</projectname>.
So it should work on all platforms supported by 
<projectname>EiffelVision2</projectname>.
</para>
</section>

<section><title>Use in scripts</title>
<para>
As far as I can see, <projectname>eimgemb</projectname> is a GUI
application, and cannot be used in scripts. On the other hand, 
<projectname>geimage</projectname> is a console application, which
makes it possible to automate the pocessing of files. For
example a script can traverse all png files in a given folder
and generate the corresponding Eiffel classes before launching
the compilation.
</para>
</section>

<section><title>Speed of generation</title>
<para>
With the png file of size 280 KB mentioned above, with
<projectname>eimgemb</projectname> takes 26 seconds to
generate the corresonding class text (not taking into
account the time to manually save it into a file).
With <projectname>geimage</projectname> this operation
is instantaneous, which is more practical when processing
tens of such png files (270 files in my case).
</para>
</section>

</chapter>
