<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>G&#039;mic tutorials</title>
	<atom:link href="http://zonderr.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://zonderr.wordpress.com</link>
	<description></description>
	<lastBuildDate>Tue, 16 Apr 2013 11:09:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='zonderr.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>G&#039;mic tutorials</title>
		<link>http://zonderr.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://zonderr.wordpress.com/osd.xml" title="G&#039;mic tutorials" />
	<atom:link rel='hub' href='http://zonderr.wordpress.com/?pushpress=hub'/>
		<item>
		<title>A G&#8217;mic lecture</title>
		<link>http://zonderr.wordpress.com/2012/05/10/a-gmic-lecture/</link>
		<comments>http://zonderr.wordpress.com/2012/05/10/a-gmic-lecture/#comments</comments>
		<pubDate>Thu, 10 May 2012 09:01:09 +0000</pubDate>
		<dc:creator>zonderr</dc:creator>
				<category><![CDATA[g'mic]]></category>

		<guid isPermaLink="false">http://zonderr.wordpress.com/?p=514</guid>
		<description><![CDATA[In march, I gave a G&#8217;mic lecture to my colleagues to show them that they should stop using anything else. I post it here because I feel it might be of some interest to someone here. It can interest you if you want to give a lecture, but it contains examples and exercises that you <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=514&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In march, I gave a G&#8217;mic lecture to my colleagues to show them that they should stop using anything else. I <a href="http://ubuntuone.com/7Ta1f9hLt0cWMsBo9DgZdD" title="A G'mic lecture">post it here</a> because I feel it might be of some interest to someone here. It can interest you if you want to give a lecture, but it contains examples and exercises that you may be just curious to check out as a G&#8217;mic student.</p>
<p><a href="http://zonderr.files.wordpress.com/2012/05/formation1.png"><img src="http://zonderr.files.wordpress.com/2012/05/formation1.png?w=510&#038;h=213" alt="" title="formation1" width="510" height="213" class="aligncenter size-full wp-image-518" /></a></p>
<p>As you&#8217;ll see, they are no slides, the lessons are just series of G&#8217;mic basic commands that, with the lecturer speech, show to the audience the different concepts of G&#8217;mic. And from time to time, there are exercises adapted to the level.</p>
<p>The intended audience was a group of 10 scientist in materials ranging from the soon to be graduate to the senior researcher. The G&#8217;mic lesson took the whole day. I wanted the difficulty level to raise steeply so that nobody could get asleep and so that we had time to see all that can be done with G&#8217;mic. This might have been an error, to progress in G&#8217;mic, one should get to know the many commands, and this requires time. The latest exercises are anyway well too difficult for beginners and are just here as a demo. The end of the day was spent discussing about the students own problems.</p>
<p><a href="http://zonderr.files.wordpress.com/2012/05/formation2.png"><img src="http://zonderr.files.wordpress.com/2012/05/formation2.png?w=290&#038;h=300" alt="" title="formation2" width="290" height="300" class="aligncenter size-medium wp-image-520" /></a></p>
<p>however, at the end, the main objective was fulfilled. They knew what they could do with G&#8217;mic, they knew where to search to continue.</p>
<p>If you feel curious, <a href="http://ubuntuone.com/7Ta1f9hLt0cWMsBo9DgZdD" title="A G'mic lecture">download the tarball</a> and check all that out.</p>
<br />Filed under: <a href='http://zonderr.wordpress.com/category/gmic/'>g'mic</a>  <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=514&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zonderr.wordpress.com/2012/05/10/a-gmic-lecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/5a21a09790b0a3dbcf83817a6388fdd5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zonderr</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2012/05/formation1.png" medium="image">
			<media:title type="html">formation1</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2012/05/formation2.png?w=290" medium="image">
			<media:title type="html">formation2</media:title>
		</media:content>
	</item>
		<item>
		<title>About the image stack</title>
		<link>http://zonderr.wordpress.com/2011/02/18/about-the-image-stack/</link>
		<comments>http://zonderr.wordpress.com/2011/02/18/about-the-image-stack/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 21:28:44 +0000</pubDate>
		<dc:creator>zonderr</dc:creator>
				<category><![CDATA[en]]></category>
		<category><![CDATA[g'mic]]></category>

		<guid isPermaLink="false">http://zonderr.wordpress.com/?p=356</guid>
		<description><![CDATA[1.Initial stack When several images are loaded in G&#8217;mic, they are ordered in a stack. It is then possible to refer to them by using either positive (starting from the first image as [0]) or negative numbers (starting from the last image as [-1]). For example, if 3 images A, B and C are loaded: <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=356&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>1.Initial stack</h3>
<p>When several images are loaded in G&#8217;mic, they are ordered in a stack. It is then possible to refer to them by using either positive (starting from the first image as [0]) or negative numbers (starting from the last image as [-1]).</p>
<p>For example, if 3 images A, B and C are loaded:</p>
<pre>gmic A.png B.png C.png</pre>
<p>It creates a stack that you can picture like that:</p>
<p><a href="http://zonderr.files.wordpress.com/2011/02/i_1.png"><img class="aligncenter size-full wp-image-480" title="3 images in the stack" src="http://zonderr.files.wordpress.com/2011/02/i_1.png?w=510" alt=""   /></a></p>
<p>You can refer to A as image [0] or image [-3], B as [1] or [-2] and C as [2] or [-1]. So both commands below do exactly the same thing, they display B:</p>
<pre>gmic A.png B.png C.png -display[1]
gmic A.png B.png C.png -display[-2]</pre>
<h3>2.Command with one dash</h3>
<p>If, in your command line, you add an instruction using a single dash, it replaces the images to which the instruction applies by the result. Thus, to split the different channels of B, the 2 commands below could be used is added to our first command:</p>
<pre>gmic A.png B.png C.png <strong>-</strong>split[1] c
gmic A.png B.png C.png <strong>-</strong>split[-2] c</pre>
<p>And they would modified the stack as shown below:<br />
<a href="http://zonderr.files.wordpress.com/2011/02/dash1.png"><img class="aligncenter size-full wp-image-484" title="Single dash" src="http://zonderr.files.wordpress.com/2011/02/dash1.png?w=510" alt=""   /></a><br />
As you can see, the image A is still [0], but not [-3] anymore, it has become [-5].</p>
<h3>3.Command with two dashes</h3>
<p>To keep the original image, instruction are called using 2 dashes. The original image is indeed kept in place and the result is added at the end of the stack.<br />
So commands below:</p>
<pre>gmic A.png B.png C.png <strong>--</strong>split[1] c
gmic A.png B.png C.png <strong>--</strong>split[-2] c</pre>
<p>would modify the stack as below:<br />
<a href="http://zonderr.files.wordpress.com/2011/02/dashdash.png"><img class="aligncenter size-full wp-image-487" title="dash dash" src="http://zonderr.files.wordpress.com/2011/02/dashdash.png?w=510" alt=""   /></a></p>
<h3>4.Stack order matters, not invoking order</h3>
<p>When you apply a command to several images, sometimes, order matters. But be careful, stack order matters, not invoking order.<br />
For example, both commands below have the same result:</p>
<pre>gmic A.png B.png -append<strong>[0,1]</strong> y
gmic A.png B.png -append<strong>[1,0]</strong> y</pre>
<p>If you want to apply your command in another order, you have to play with the image stack, such as:</p>
<pre>gmic A.png B.png <strong>-reverse[0,1]</strong> -append[0,1] y</pre>
<p>or</p>
<pre>gmic A.png B.png <strong>-move[1] 0</strong> -append[1,0] y</pre>
<br />Filed under: <a href='http://zonderr.wordpress.com/category/en/'>en</a>, <a href='http://zonderr.wordpress.com/category/gmic/'>g'mic</a> Tagged: <a href='http://zonderr.wordpress.com/tag/gmic/'>g'mic</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=356&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zonderr.wordpress.com/2011/02/18/about-the-image-stack/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/5a21a09790b0a3dbcf83817a6388fdd5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zonderr</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2011/02/i_1.png" medium="image">
			<media:title type="html">3 images in the stack</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2011/02/dash1.png" medium="image">
			<media:title type="html">Single dash</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2011/02/dashdash.png" medium="image">
			<media:title type="html">dash dash</media:title>
		</media:content>
	</item>
		<item>
		<title>Comment créer un filtre dans le greffon G&#8217;mic ?</title>
		<link>http://zonderr.wordpress.com/2011/02/11/comment-creer-un-filtre-dans-le-greffon-gmic/</link>
		<comments>http://zonderr.wordpress.com/2011/02/11/comment-creer-un-filtre-dans-le-greffon-gmic/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 21:37:11 +0000</pubDate>
		<dc:creator>zonderr</dc:creator>
				<category><![CDATA[fr]]></category>
		<category><![CDATA[g'mic]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://zonderr.wordpress.com/?p=455</guid>
		<description><![CDATA[0-Introduction Ce tutoriel a pour but de montrer comment créer un filtre personnalisé pour le greffon G&#8217;mic pour Gimp. Il part du principe que le lecteur ne connaît pas du tout le langage en ligne de commande G&#8217;mic. Vous pouvez trouver des informations sur la façon de faire un filtre au début du fichier de <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=455&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>0-Introduction</h3>
<p>Ce tutoriel a pour but de montrer comment créer un filtre personnalisé pour le <a href="http://gmic.sourceforge.net/gimp.shtml">greffon G&#8217;mic pour Gimp</a>. Il part du principe que le lecteur ne connaît pas du tout le langage en ligne de commande G&#8217;mic.</p>
<p>Vous pouvez trouver des informations sur la façon de faire un filtre au début du <a href="http://cimg.cvs.sourceforge.net/viewvc/cimg/CImg/examples/gmic_def.gmic">fichier de commandes personnalisées par défaut</a> et directement dans le greffon dans <code>A propos &gt; Création de filtres</code> et aussi ci-dessous.</p>
<p>Ici, vous serez d&#8217;abord invité à créer un filtre très simple afin de comprendre les bases puis il s&#8217;agira d&#8217;assembler différents filtres afin d&#8217;en créer un meilleur.</p>
<h3 id="mon_premier_filtre">1-Mon premier filtre</h3>
<h4>1.1-Le fichier des filtres personnalisés</h4>
<p>Tous les filtres personnalisés que vous faites doivent être écrits dans un unique fichier texte appelé &#8220;<code>.gmic</code>&#8220;, n&#8217;oubliez pas le point au début du nom et n&#8217;ajouter rien d&#8217;autre, le nom de votre fichier texte n&#8217;est constitué que d&#8217;un point et de 4 lettres:: &#8220;<code>.gmic</code>&#8220;. Vous devez créer ce fichier dans votre répertoire &#8220;<code>home</code>&#8221; si vous êtes sous Linux, dans votre répertoire <code>Application Data</code> si vous êtes sous Windows et dans votre  <code>User Home folder</code> si vous êtes sous MacOS. Ces 2 derniers systèmes d&#8217;exploitations peuvent rendre difficile la création de fichier commençant par un point: notepad or TextEdit peuvent vous aider au besoin.</p>
<h4>1.2-Le filtre apparaît</h4>
<p>Pour apparaître dans le greffon, vous devez inclure une ligne qui commence par <code>#@gimp</code> donnant le nom de votre filtre, la commande associée à ce filtre et optionnellement, la commande pour créer l&#8217;aperçu. Quelque chose comme:</p>
<pre>#@gimp Mon premier filtre: mon_premier_filtre_commande, mon_premier_filtre_commande_preview</pre>
<p>Vous pouvez essayer, mettez cette ligne dans votre fichier <code>.gmic</code>, rafraichissez les filtres G&#8217;mic et il devrait apparaître en haut de vos <code>Filtres disponibles</code>.</p>
<h4 id="filtre_dit_qqchose">1.3-Le filtre dit quelque chose</h4>
<p>Dans la partie droite de la fenêtre du greffon, vous pouvez mettre du texte et proposer différentes sortes de variables utilisables par le filtre. Pour cela, vous devez encore ajouter des lignes commençant par <code>#@gimp</code>. Vous pouvez par exemple recopier les lignes ci-dessous dans votre fichier <code>.gmic</code> et rafraîchir les filtres.</p>
<pre>#@gimp Mon premier filtre: mon_premier_filtre_commande, mon_premier_filtre_commande
#@gimp : note = note("C'est mon premier filtre, je suis tellement excité!")
#@gimp : sep = separator()
#@gimp : Angle = float(45,0,360)
#@gimp : Remplir l'espace vide = choice("en noir","comme les bords","en répétant l'image")</pre>
<h4>1.4-Le filtre fait quelque chose</h4>
<p>Jusqu&#8217;ici, votre filtre ne marche pas, si vous cliquer sur <code>Valider</code>, une erreur apparaîtra. C&#8217;est parce qu&#8217;aucune commande ne s&#8217;appelle &#8220;<code>mon_premier_filtre_commande</code>&#8220;, elle doit être créée en utilisant le langage G&#8217;mic. Donc, notre premier filtre peut être fini avec 2 lignes supplémentaires pour devenir:</p>
<pre>#@gimp Mon premier filtre: mon_premier_filtre_commande, mon_premier_filtre_commande
#@gimp : note = note("C'est mon premier filtre, je suis tellement excité!")
#@gimp : sep = separator()
#@gimp : Angle = float(45,0,360)
#@gimp : Remplir l'espace vide = choice("en noir","comme les bords","en répétant l'image")
<strong>mon_premier_filtre_commande :
  -rotate $1,$2</strong></pre>
<p>si vous mettez ceci dans votre fichier <code>.gmic</code> et rafraichissez les filtres une fois de plus, vous avez un filtre pleinement fonctionnel capable de tourner une image. Vous pouvez ajuster l&#8217;angle de rotation de 0 à 360° et la valeur proposée par défaut est 45. Vous avez 3 choix pour &#8220;remplir l&#8217;espace vide&#8221;.<br />
La commande utilisée par votre filtre est &#8220;<code>mon_premier_filtre_commande</code>&#8221; et c&#8217;est une commande très simple qui utilise l&#8217;instruction <code>-rotate</code> et les 2 variables $1 et $2 font référence à celles proposées au-dessus: &#8220;Angle&#8221; et &#8220;Remplir l&#8217;espace vide&#8221;.</p>
<h4>1.5-Le filtre fait ce que vous voulez</h4>
<p>Maintenant, vous avez les bases, vous avez juste besoin de vous inspirer des filtres déjà disponibles et <a href="http://cimg.cvs.sourceforge.net/viewvc/cimg/CImg/examples/gmic_def.gmic">de leur code source</a> et si vous ne le connaissez pas encore, apprenez <a href="http://zonderr.wordpress.com/2010/10/09/initiation-au-langage-gmic/">le langage de programmation G&#8217;mic</a>. Pour ceux encore réticents à son apprentissage, il est possible d&#8217;assembler des filtres déjà existant en connaissant juste quelques trucs en plus.</p>
<h3>2-Assembler des filtres</h3>
<p>Après avoir utilisé le greffon, vous trouvez peut-être que ce serait bien si certains de vos filtres favoris pouvaient être assemblés afin de minimiser le nombre de clics. C&#8217;est d&#8217;une certaine façon possible.</p>
<h4>2.1-Mimer un travail séquentiel</h4>
<p>Si votre travail est purement séquentiel, c.à.d. si vous appliquez votre premier filtre sur une image, puis vous appliquez votre second filtre sur le résultat obtenu, etc. il est alors relativement facile de créer un filtre qui effectue les deux en un seul clic. Pour ça, vous devez récupérer les lignes de commandes exécutées par le greffon et les utiliser pour recréer un filtre comme expliqué au <a href="http://zonderr.wordpress.com/2011/02/11/comment-creer-un-filtre-dans-le-greffon-gmic/#mon_premier_filtre">premier chapitre</a>.<br />
Par exemple, imaginons que vous vouliez assembler <code>B&amp;W pencil</code> suivi de <code>Soft glow</code> (tous deux dans le répertoire <code>Artistic folder</code>). Pour récupérer la ligne de commande, la façon la plus facile est <a href="http://zonderr.wordpress.com/2010/09/18/gmic-from-the-gimp-plugin-to-the-command-line/">d&#8217;exécuter Gimp depuis un terminal et de régler les messages de sortie du greffon sur verbeux</a>. Pour les 2 filtres en questions, vous obtiendriez dans votre console (ou votre fichier log) des lignes intéressantes comme:</p>
<pre>[gmic_gimp]./apply/ -v -99 -gimp_pencilbw 0.3,60,0,0,0
[gmic_gimp]./apply/ -v -99 -gimp_glow 1,0,0</pre>
<p>Votre nouveau filtre peut alors être écrit:</p>
<pre>#@gimp BWpencil et Glow: bwpencil_glow, bwpencil_glow
bwpencil_glow :
  -gimp_pencilbw 0.3,60,0,0,0
  -gimp_glow 1,0,0</pre>
<p>Et cela marche de la même façon avec 3, 4 et plus de filtres.</p>
<h4>2.2-Proposer des réglages</h4>
<p>Mais vous aurez remarqué (si vous l&#8217;avez essayé), il n&#8217;y a pas de réglages proposés dans l&#8217;assemblage de filtres. Pour en ajouter, vous devez faire comme expliqué <a href="http://zonderr.wordpress.com/2011/02/11/comment-creer-un-filtre-dans-le-greffon-gmic/#filtre_dit_qqchose"> ci-dessus</a>. Ainsi, si vous voulez pouvoir régler la taille et l&#8217;amplitude pour <code>B&amp;W pencil</code> et l&#8217;amplitude pour <code>Soft glow</code>, vous adapterez de cette façon:</p>
<pre>#@gimp BWpencil and Glow: bwpencil_glow, bwpencil_glow
#@gimp : taillle = float(0.3,0,5)
#@gimp : Amplitude pour B&amp;W pencil= float(60,0,200)
#@gimp : Amplitude pour Soft glow = float(1,0,20)
bwpencil_glow :
  -gimp_pencilbw $1,$2,0,0,0
  -gimp_glow $3,0,0</pre>
<h4>2.3-Assemblage complexe</h4>
<p>Les choses deviennent plus compliquées quand vous gérer plusieurs images pendant la séquence de filtres que vous voulez assembler. Cela arrive, par exemple, si vous conservez l&#8217;original en réglant le <code>Mode de sortie</code> sur <code>Nouveau(x) calque(s)</code> (ou <code>Nouveau(x) quoique ce soit</code>) ou si un de vos filtres initiaux créent plusieurs images (comme <code>Layers &gt; Tiles to layers</code> ou <code>Layers &gt; Split tones</code>). Vous pouvez maitrisez cela en apprenant 2 autres petits trucs faciles du langage G&#8217;mic.</p>
<h5>2.3.1-Conserver l&#8217;original</h5>
<p>Jusqu&#8217;à maintenant, pour appeler une commande G&#8217;mic, vous mettiez un tiret (-) suivi du nom de la commande, par exemple:</p>
<pre>  -gimp_pencilbw 0.3,60,0,0,0</pre>
<p>Et bien, si vous mettez 2 tirets à la place, G&#8217;mic procède de la même façon avec les images, mais il conservera aussi l&#8217;original. Si vous essayez le filtre ci-dessous, même si vous réglez le <code>Mode de sortie</code> sur <code>Sur place</code>, vous obtenez votre résultats dans un nouveau calque:</p>
<pre>#@gimp Keep BWpencil : keep_bwpencil, keep_bwpencil
keep_bwpencil :
  <strong>--</strong>gimp_pencilbw 0.3,60,0,0,0</pre>
<h5>2.3.2-Gérer plusieurs images</h5>
<p>Pour gérer plusieurs images, G&#8217;mic leur donne des numéros commençant par 0. Donc, dans l&#8217;exemple précédent, votre image originale serait la numéro 0 et celle créée par le <code>B&amp;W pencil</code> serait la numéro 1.<br />
Si vous ne spécifiez rien, par défaut, la commande suivante est appliquée à toutes les images. Par exemple, dans le filtre qui suit, <code>Soft glow</code> est appliqué sur l&#8217;originale et sur celle provenant de <code>B&amp;W pencil</code>.</p>
<pre>#@gimp Keep BWpencil plus glow : keep_bwpencil_glow, keep_bwpencil_glow
keep_bwpencil_glow :
  --gimp_pencilbw 0.3,60,0,0,0
  -gimp_glow 1,0,0</pre>
<p>Mais, si vous accolez le numéro de l&#8217;image entre crochets à votre nom de commande, alors le filtre ne sera appliqué qu&#8217;à l&#8217;image spécifiée. Ainsi, si vous modifiez le filtre précédent comme ci-dessous, le <code>Soft glow</code> n&#8217;est exécuté que sur l&#8217;image résultant de <code>B&amp;W pencil</code>, laissant l&#8217;originale intacte:</p>
<pre>#@gimp Keep BWpencil plus glow : keep_bwpencil_glow, keep_bwpencil_glow
keep_bwpencil_glow :
  --gimp_pencilbw 0.3,60,0,0,0
  -gimp_glow<strong>[1]</strong> 1,0,0</pre>
<p>Vous pouvez spécifiquement demander à un filtre de s&#8217;exécuter sur plusieurs images en ajoutant d&#8217;autres nombres séparés par une virgule. Pour filtrer la première, la troisième et la cinquième, vous accoleriez [0,2,4] au nom de votre commande. Il y en <a href="http://zonderr.wordpress.com/2010/10/09/initiation-au-langage-gmic/#some_images">plus</a> à savoir à ce <a href="http://zonderr.wordpress.com/2011/02/18/about-the-image-stack/">sujet</a>.</p>
<h5>2.3.2-Finissions ce machin</h5>
<p>Au point où on en est, ce filtre me semble non-fini. J&#8217;ai l&#8217;impression qu&#8217;il pourrait être utile à quelqu&#8217;un si les 2 calques obtenus étaient recomposés ensemble avec une sorte de <code>Layers Multiply</code> et si quelques possibilités de réglage étaient offertes à l&#8217;utilisateur. Et puisque 2 filtres ont été construits pendant ce tutoriel, mettons-les tous les deux dans le fichier <code>.gmic</code> afin qu&#8217;ils puissent tous deux être utilisés dans le greffon. En totalité, cela ressemblera à quelque chose comme:</p>
<pre>#@gimp Mon premier filtre: mon_premier_filtre_commande, mon_premier_filtre_commande
#@gimp : note = note("C'est mon premier filtre, je suis tellement excité!")
#@gimp : sep = separator()
#@gimp : Angle = float(45,0,360)
#@gimp : Remplir l'espace vide = choice("en noir","comme les bords","en répétant l'image")
mon_premier_filtre_commande :
  -rotate $1,$2

#@gimp Filtre du tutoriel  : filtre_tuto, filtre_tuto
#@gimp : Size = float(0.3,0,5)
#@gimp : Amplitude pour B&amp;W pencil= float(60,0,200)
#@gimp : Amplitude pour Soft glow = float(1,0,20)
filtre_tuto :
  --gimp_pencilbw $1,$2,0,0,0
  -gimp_glow[1] $3,0,0
  -compose_multiply</pre>
<h4>2.4-Pour aller plus loin</h4>
<p>Puisque qu&#8217;il s&#8217;agit de programmation, il est probable que vous rencontriez quelques bugs. Pour debugger, penser à régler les <code>Messages de sortie</code> sur <code>Mode verbeux</code> ou <code>Très verbeux</code>. Et ne restez pas bloqués seuls <a title="one active forum" href="http://www.flickr.com/groups/gmic/">venez trouver inspiration et aide et partager ce que vous avez fait</a>.<br />
Une fois que vous aurez un peu jouer, vous voudrez peut-être apprendre <a title="Making better filtres" href="http://zonderr.wordpress.com/2010/12/02/gmic-making-a-better-plug-in/">quelques trucs en plus</a>.</p>
<br />Filed under: <a href='http://zonderr.wordpress.com/category/fr/'>fr</a>, <a href='http://zonderr.wordpress.com/category/gmic/'>g'mic</a>, <a href='http://zonderr.wordpress.com/category/plugin/'>plugin</a> Tagged: <a href='http://zonderr.wordpress.com/tag/gmic/'>g'mic</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=455&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zonderr.wordpress.com/2011/02/11/comment-creer-un-filtre-dans-le-greffon-gmic/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/5a21a09790b0a3dbcf83817a6388fdd5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zonderr</media:title>
		</media:content>
	</item>
		<item>
		<title>Custom command for the command line</title>
		<link>http://zonderr.wordpress.com/2011/02/07/custom-command-for-the-command-line/</link>
		<comments>http://zonderr.wordpress.com/2011/02/07/custom-command-for-the-command-line/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 13:50:43 +0000</pubDate>
		<dc:creator>zonderr</dc:creator>
				<category><![CDATA[en]]></category>
		<category><![CDATA[g'mic]]></category>

		<guid isPermaLink="false">http://zonderr.wordpress.com/?p=367</guid>
		<description><![CDATA[0-Introduction It is possible and easy to make your own custom command in G&#8217;mic. It is written in a file that has to be called when needed. 1-The G&#8217;mic command file The custom commands you define have to be written in a text file. Its name is supposed to finish by the .gmic extension, but <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=367&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>0-Introduction</h3>
<p>It is possible and easy to make your own custom command in G&#8217;mic. It is written in a file that has to be called when needed.</p>
<h3>1-The G&#8217;mic command file</h3>
<p>The custom commands you define have to be written in a text file. Its name is supposed to finish by the <code>.gmic</code> extension, but it isn&#8217;t compulsory. It is called using the command <code>-command</code> or its shortcut <code>-m</code> or by no command at all if its extension is indeed <code>.gmic</code>.</p>
<p>So, let&#8217;s say you want to use your own command called <code>my_custom_command</code> that you wrote in a file called <code>macros.gmic</code> on a picture called <code>image.jpg</code>. Then the 3 following commands are valid and equivalent:</p>
<pre>gmic image.jpg -command macros.gmic -my_custom_command
gmic image.jpg -m macros.gmic -my_custom_command
gmic image.jpg macros.gmic -my_custom_command</pre>
<p>If you have already made some custom filters for the <a title="How to create a custom filter in the G’mic plug-in" href="http://zonderr.wordpress.com/2010/11/13/howto-create-a-custom-filter-in-the-gmic-plug-in/">plugin</a>, you can use them by calling the file named <code>.gmic</code> in your home directory. In linux, this is done for example this way:</p>
<pre>gmic image.jpg ~/.gmic -my_custom_command</pre>
<h3>2-Building that <code>my_custom_command</code></h3>
<h4>2.1-Define it</h4>
<p>To define a custom command, just write the command name followed by a space and a colon in your G&#8217;mic file. So if you write the line below :</p>
<pre>my_custom_command :</pre>
<p>it is defined. And if you use it:</p>
<pre>gmic image.jpg macros.gmic -my_custom_command</pre>
<p>It won&#8217;t return any error, even if it doesn&#8217;t do anything so far.</p>
<h4>2.2-Give it orders</h4>
<p>To have your custom command do something, just write what it should do below in a usual G&#8217;mic language, ex:</p>
<pre>my_custom_command :
  -rotate 45
  -resize 50%,50%</pre>
<h4>2.3-Arguments</h4>
<h5>2.3.1-Just arguments</h5>
<p>Arguments can be used in your custom command, for example, it can become:</p>
<pre>my_custom_command :
  -rotate <strong>$1</strong>
  -resize <strong>$2</strong>,<strong>$2</strong></pre>
<p>But from now on, you should not forget to specify arguments when you call it:</p>
<pre>gmic image.jpg macros.gmic -my_custom_command 45,50%</pre>
<h5>2.3.1-Setting default arguments</h5>
<p>So far, if you forget to specify one argument, you get an error message. It might be better to propose some default setting. It is usually done using the <code>-skip</code> command like this:</p>
<pre>my_custom_command : <strong>-skip ${1=45},${2=50%}</strong>
  -rotate $1
  -resize $2,$2</pre>
<p>Now, you don&#8217;t have to specify any argument, you can, but if you don&#8217;t, the default ones are applied. The 3 lines below now thus produce the same output:</p>
<pre>gmic image.jpg macros.gmic -my_custom_command
gmic image.jpg macros.gmic -my_custom_command 45
gmic image.jpg macros.gmic -my_custom_command 45,50%</pre>
<h5>2.3.2-Checking arguments validity</h5>
<p>To avoid weird behavior and for cleanliness, it is sometime better to check the validity of an argument. For instance, it is wise to avoid a negative argument for the <code>-resize</code> function. This is done with <code>-check</code>:</p>
<pre>my_custom_command : -skip ${1=45} <strong>-check ${2=50%}&gt;0</strong>
  -rotate $1
  -resize $2,$2</pre>
<p>Like this, in case of negative second argument:</p>
<pre>gmic image.jpg macros.gmic -my_custom_command 45,<strong>-400</strong></pre>
<p>you get an explicit error message:</p>
<pre>[gmic]-1./my_custom_command/ *** Error in ./my_custom_command/ *** <strong>Command 'check' : expression '-400&gt;0' is false.</strong></pre>
<h3>3-Polishing it</h3>
<p>So far, the custom command does its job as it should, but it is still possible to improve it.</p>
<h4>3.1-Comments in the code</h4>
<p>You can add comments in the code with the hash (#) :</p>
<pre>my_custom_command : -skip ${1=45} -check ${2=50%}&gt;0
 -rotate $1  <strong># to make it rotate</strong>
<strong># and then it will be resized!</strong>
  -resize $2,$2</pre>
<h4>3.2-Comments in the terminal</h4>
<p>So far, if you look at your terminal, you get to know every steps of your custom command:</p>
<pre>[gmic]-1./my_custom_command/ Rotate image [0] of 45 degree, dirichlet borders and linear interpolation.
[gmic]-1./my_custom_command/ Resize image [0] to 50%x50%x100%x100% , with nearest neighbor interpolation, dirichlet borders and centering (0,0,0,0).</pre>
<p>But you might feel it lighter if you only get one line considering your custom command as a whole. This is done by reducing the verbosity during the execution of you command, using <code>-v -</code> at the start and <code>-v +</code> at the end.<br />
Then add your own comment before everything with <code>-echo[^-1]</code> (or its shortcut <code>-e[^-1]</code>). For example:</p>
<pre>my_custom_command : -skip ${1=45} -check ${2=50%}&gt;0
  <strong>-e[^1] "My rotate-resize of $1 and $2 on image$?"</strong>
  <strong>-v -</strong>
  -rotate $1
  -resize $2,$2
  <strong>-v +</strong></pre>
<p>lets in the terminal:</p>
<pre>[gmic]-1./ My rotate-resize of 45 and 50% on image [0]</pre>
<h4>3.3-Help message</h4>
<p>To make everything slicker, it is also possible to add some help message meant to be displayed in case of error. For that, start the command description with:</p>
<pre>#@gmic my_custom_command</pre>
<p>and then add informations with lines starting this way:</p>
<pre>#@gmic :</pre>
<p>At the end, the code might look:</p>
<pre><strong>
#@gmic my_custom_command : _angle, pixel size
#@gmic : This crappy custom command
#@gmic : just rotate and resize
</strong>my_custom_command : -check "${2=50%}&gt;0"
  -e[^1] "My rotate-resize of $1 and $2 on image$?"
  -v -
  -rotate $1
  -resize $2,$2
  -v +</pre>
<p>Now if you type something wrong:</p>
<pre>gmic image.jpg macros.gmic -my_custom_command 45,<strong>-400</strong></pre>
<p>You get some help:</p>
<pre>[gmic] Command 'my_custom_command' has the following description : 

    -my_custom_command _angle, pixel size       

        This crappy custom command
        just rotate and resize</pre>
<h3>4.And then</h3>
<p>You can put as many custom command as you want in one G&#8217;mic file. You can now easily make loops (-repeat &#8230; -done), if statement (-if &#8230; -elif &#8230; -else &#8230; -endif), use variables (foo=&#8221;bar&#8221; &#8230; -e $foo) and so on.</p>
<br />Filed under: <a href='http://zonderr.wordpress.com/category/en/'>en</a>, <a href='http://zonderr.wordpress.com/category/gmic/'>g'mic</a> Tagged: <a href='http://zonderr.wordpress.com/tag/gmic/'>g'mic</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=367&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zonderr.wordpress.com/2011/02/07/custom-command-for-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/5a21a09790b0a3dbcf83817a6388fdd5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zonderr</media:title>
		</media:content>
	</item>
		<item>
		<title>G&#8217;mic : Making better custom filters</title>
		<link>http://zonderr.wordpress.com/2010/12/02/gmic-making-a-better-plug-in/</link>
		<comments>http://zonderr.wordpress.com/2010/12/02/gmic-making-a-better-plug-in/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 21:23:00 +0000</pubDate>
		<dc:creator>zonderr</dc:creator>
				<category><![CDATA[en]]></category>
		<category><![CDATA[g'mic]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://zonderr.wordpress.com/?p=306</guid>
		<description><![CDATA[0-Introduction Here, it is supposed that you read the previous article on the subject and are ready for more. The official goal is give tricks to make slicker and more reliable filters. 1-Better preview 1.1-Default zoom You can specify what should be the default zoom for your preview by pasting a float number between parenthesis <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=306&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>0-Introduction</h3>
<p>Here, it is supposed that you read the<a title="How to create a custom filter in the G’mic plug-in" href="http://zonderr.wordpress.com/2010/11/13/howto-create-a-custom-filter-in-the-gmic-plug-in"> previous article</a> on the subject and are ready for more. The official goal is give tricks to make slicker and more reliable filters.</p>
<h3>1-Better preview</h3>
<h4>1.1-Default zoom</h4>
<p>You can specify what should be the default zoom for your preview by pasting a float number between parenthesis to the preview command at the first line end of your custom filter. Ex:</p>
<pre>#@gimp Better Filter  : better_filter, better_filter_preview<strong>(0)</strong></pre>
<p>(0) means 1:1 preview, (1) means previewing the whole image, (2) means 1/2 image and so on&#8230;</p>
<h4>1.2-Split preview</h4>
<p>You must have seen that some filters propose a split preview, so you can accurately compare the existing image with the future filtered one. You can add this functionality to your filter if you:</p>
<ol>
<li> add a new choice option dedicated to the preview type and</li>
<li>embed your filter command inside the <code>-gimp_split_preview</code> command.</li>
</ol>
<p>The filter from the<a title="How to create a custom filter in the G’mic plug-in" href="../2010/11/13/howto-create-a-custom-filter-in-the-gmic-plug-in"> previous article</a> would become:</p>
<pre>#@gimp Better Filter  : better_filter, better_filter_preview(0)
#@gimp : Size = float(0.3,0,5)
#@gimp : Amplitude for B&amp;W pencil= float(60,0,200)
#@gimp : Amplitude for Soft glow = float(1,0,20)
#@gimp : sep = separator()
<strong>#@gimp : Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical")</strong>
better_filter :
  --gimp_pencilbw $1,$2,0,0,0
  -gimp_glow[1] $3,0,0
  -compose_multiply
better_filter_preview :
<strong>  -gimp_split_preview "-better_filter ${1--2}",$-1</strong></pre>
<p><a href="http://zonderr.files.wordpress.com/2010/12/shaving_filter_preview.png"><img class="aligncenter size-medium wp-image-347" title="Split preview example" src="http://zonderr.files.wordpress.com/2010/12/shaving_filter_preview.png?w=400&#038;h=221" alt="" width="400" height="221" /></a></p>
<p style="text-align:center;">Thanks to<strong> <a href="http://www.flickr.com/photos/editor/3370897686">Editor B</a></strong>, <a href="http://creativecommons.org/licenses/by/2.0/">CC-by</a></p>
<h3>2-Multiple input management</h3>
<h4>2.1-A possible issue</h4>
<p>As a user, if you have several layers and want to apply the filter above on each of them, you might feel natural to just set the <code>Input layer</code> option to <code>All</code> and proceed. But with the filter as it is right now, you won&#8217;t get the expected result.<br />
This is because the <code>-gimp_pencilbw</code> and the <code>-compose_multiply</code> commands are applied on every layers without discernment. To address this issue, one solution is to create a loop inside which, each layer is considered one by one.</p>
<h4>2.2-The saving loop</h4>
<p>For that, you create a &#8220;<code>-repeat ... -done</code>&#8221; loop that runs as many times as you have layers. Then, inside that loop, you isolate the layer that has to be processed this time with a &#8220;<code>-local ... -endlocal</code>&#8221; block. The filter then becomes:</p>
<pre>#@gimp Better Filter  : better_filter, better_filter_preview(0)
#@gimp : Size = float(0.3,0,5)
#@gimp : Amplitude for B&amp;W pencil= float(60,0,200)
#@gimp : Amplitude for Soft glow = float(1,0,20)
#@gimp : sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical")
better_filter :
  <strong>-repeat @# -local[@{&gt;,-1}]</strong>
  --gimp_pencilbw $1,$2,0,0,0
  -gimp_glow[1] $3,0,0
  -compose_multiply
  <strong>-endlocal -done</strong>
better_filter_preview :
  -gimp_split_preview "-better_filter ${1--2}",$-1</pre>
<p>The variable <code>@#</code> returns the number of layers. If you have 3 layers the code inside the loop will be run 3 times.<br />
The variable <code>~&gt;</code> is the counter telling you how many times the loop has been run so far. So, for 3 layers, it takes successively the values 0,1,2.<br />
Only one layer enter the &#8220;<code>-local[~&gt;] ... -endlocal</code>&#8221; block, and inside that block, it is considered as being number [0].</p>
<h3>3-Sort out your filters</h3>
<p>Having many custom filters in your .gmic file can create a mess in your plug-in window. To sort out that, you can create directories! The next line means : &#8220;everything that follows will be placed in the directory called: My Directory&#8221;</p>
<pre>#@gimp My Directory</pre>
<p>Whereas that one means : &#8220;everything that follows will be in the parent directory&#8221;</p>
<pre>#@gimp _</pre>
<p>So put the first one at the top of your .gmic file and the second one at the bottom and things are sorted out.</p>
<br />Filed under: <a href='http://zonderr.wordpress.com/category/en/'>en</a>, <a href='http://zonderr.wordpress.com/category/gmic/'>g'mic</a>, <a href='http://zonderr.wordpress.com/category/plugin/'>plugin</a> Tagged: <a href='http://zonderr.wordpress.com/tag/gmic/'>g'mic</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=306&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zonderr.wordpress.com/2010/12/02/gmic-making-a-better-plug-in/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/5a21a09790b0a3dbcf83817a6388fdd5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zonderr</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2010/12/shaving_filter_preview.png?w=300" medium="image">
			<media:title type="html">Split preview example</media:title>
		</media:content>
	</item>
		<item>
		<title>How to create a custom filter in the G&#8217;mic plug-in</title>
		<link>http://zonderr.wordpress.com/2010/11/13/howto-create-a-custom-filter-in-the-gmic-plug-in/</link>
		<comments>http://zonderr.wordpress.com/2010/11/13/howto-create-a-custom-filter-in-the-gmic-plug-in/#comments</comments>
		<pubDate>Sat, 13 Nov 2010 19:26:17 +0000</pubDate>
		<dc:creator>zonderr</dc:creator>
				<category><![CDATA[en]]></category>
		<category><![CDATA[g'mic]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://zonderr.wordpress.com/?p=223</guid>
		<description><![CDATA[0-Introduction This tutorial intends to show how to create a so called user-defined filter in the G&#8217;mic plug-in for Gimp. It supposes that you don&#8217;t know anything in the G&#8217;mic command line language. You can find some quick informations on how to make such a filter close to the beginning of the default custom command <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=223&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>0-Introduction</h3>
<p>This tutorial intends to show how to create a so called user-defined filter in the <a href="http://gmic.sourceforge.net/gimp.shtml">G&#8217;mic plug-in for Gimp</a>. It supposes that you don&#8217;t know anything in the G&#8217;mic command line language.</p>
<p>You can find some quick informations on how to make such a filter close to the beginning of the <a href="http://cimg.cvs.sourceforge.net/viewvc/cimg/CImg/examples/gmic_def.gmic">default custom command file </a>and directly in the plug-in at <code>About &gt; Filters design</code> and here below.</p>
<p>Below, you will be first invited to create a pretty simple filter to understand the basis and then the purpose will be to assemble different filters in order to create a better one.</p>
<h3 id="my_first_filter">1-My first filter</h3>
<h4>1.1-The user-defined filter file</h4>
<p>All the user-defined filters that you make have to be written in one single text file called &#8220;<code>.gmic</code>&#8221; under linux or MacOS and only &#8220;gmic&#8221; under Windows (there&#8217;s a dot at the start of the filename under linux or MacOS, not under Windows). You need to create that file in your <code>home</code> directory if you are under linux or MacOS and in your <code>Application Data</code> folder if your are under Windows. For those having difficulties to create a file beginning with a dot under MacOS, use TextEdit.</p>
<h4>1.2-The filter appears</h4>
<p>To appear in the plug-in, you should include a line starting by <code>#@gimp</code> giving your filter&#8217;s name, the command name associated with that filter and optionally, a command name to create the preview. Something like that:</p>
<pre>#@gimp My first filter: my_first_filter_command, my_first_filter_command_preview</pre>
<p>You can try, put it in your <code>.gmic</code> file, refresh the G&#8217;mic filter and it should appear at the top of the available filters.</p>
<h4 id="filter_says_something">1.3-The filter says something</h4>
<p>In the right part of the plug-in window, you can put text and propose different kinds of variables that can be used by the filter command. For that you need again lines beginning by <code>#@gimp</code>. As an example, you can paste the lines below in your <code>.gmic</code> file and refresh your filter.</p>
<pre>#@gimp My first filter: my_first_filter_command, my_first_filter_command
#@gimp : note = note("It is my first filter, I am so excited!")
#@gimp : sep = separator()
#@gimp : Angle = float(45,0,360)
#@gimp : Fill the empty space = choice("in black","like the borders","by repeating the image")</pre>
<h4>1.4-The filter does something</h4>
<p>So far, your filter doesn&#8217;t work, If you click on <code>apply</code>, an error message will appear. It is because no command is called &#8220;<code>my_first_filter_command</code>&#8220;, it has to be created using the G&#8217;mic command line language. So, our first filter can be completed with 2 more lines to become:</p>
<pre>#@gimp My first filter: my_first_filter_command, my_first_filter_command
#@gimp : note = note("It is my first filter, I am so excited!")
#@gimp : sep = separator()
#@gimp : Angle = float(45,0,360)
#@gimp : Fill the empty space = choice("in black","like the borders","by repeating the image")
<strong>my_first_filter_command :
  -rotate $1,$2</strong></pre>
<p>if you put that in your <code>.gmic</code> file and refresh once again the filter, you now have a fully functional filter able to rotate an image. You can adjust the rotation angle from 0 to 360° and the default proposed value is 45. You have 3 choices to &#8220;fill the empty space&#8221;.</p>
<p>The command used for your filter is called &#8220;<code>my_first_filter_command</code>&#8221; and it is a quite simple command that use the <code>-rotate</code> instruction and the two variables $1 and $2 refer to the 2 ones proposed above: &#8220;angle&#8221; and &#8220;fill the empty space&#8221;.</p>
<h4>1.5-The filter does what you want</h4>
<p>Now you know the basis, you just have to get inspired by the already available filters and <a href="http://cimg.cvs.sourceforge.net/viewvc/cimg/CImg/examples/gmic_def.gmic">their source code</a> and if you don&#8217;t already know it, learn <a href="http://zonderr.wordpress.com/2010/09/13/gmic-command-first-steps/">the G&#8217;mic programming language</a>. For those of you still reluctant to learn it, by just knowing a few more things, it is possible to assemble already existing filters.</p>
<h3>2-Assembling filters</h3>
<p>After some use of the G&#8217;mic plug-in, you might feel that it would be great if some of your favorite filters would be assembled together in order to minimize the number of click. It is somehow possible.</p>
<h4>2.1-Mimic a sequential work</h4>
<p>If your work is purely sequential, i.e. you apply the first filter on an image, then you apply the second filter on the result etc. then it is relatively easy to create a filter that do both in just one click. For that, you need to get the command lines run in the background of the plug-in and use them to recreate a filter as explained in the <a href="http://zonderr.wordpress.com/2010/11/13/howto-create-a-custom-filter-in-the-gmic-plug-in/#my_first_filter">first chapter</a>.</p>
<p>For example, let&#8217;s imagine that you want to assemble <code>B&amp;W pencil</code> followed by <code>Soft glow</code> (both in the Artistic folder). To get the command lines run for those filters, the easiest way is to <a href="http://zonderr.wordpress.com/2010/09/18/gmic-from-the-gimp-plugin-to-the-command-line/">run gimp from a terminal and to set the plug-in to verbose</a>. For the 2 filters, you would get in your terminal some interesting lines like:</p>
<pre>[gmic_gimp]./apply/ -v -99 -gimp_pencilbw 0.3,60,0,0,0
[gmic_gimp]./apply/ -v -99 -gimp_glow 1,0,0</pre>
<p>Then your new filter can be written:</p>
<pre>#@gimp BWpencil and Glow: bwpencil_glow, bwpencil_glow
bwpencil_glow :
  -gimp_pencilbw 0.3,60,0,0,0
  -gimp_glow 1,0,0</pre>
<p>And it works the same with 3, 4 and more filters.</p>
<h4>2.2-Propose some settings</h4>
<p>But you might have noticed (if you tried it), there is no setting proposed in the assembled filter. To add some, you need to do as explained <a href="http://zonderr.wordpress.com/2010/11/13/howto-create-a-custom-filter-in-the-gmic-plug-in/#filter_says_something"> above</a>. Thus if you want to be able to set the size and amplitude for the <code>B&amp;W pencil</code> and the amplitude for the <code>Soft glow</code>, you would adapt the filter this way:</p>
<pre>#@gimp BWpencil and Glow: bwpencil_glow, bwpencil_glow
#@gimp : Size = float(0.3,0,5)
#@gimp : Amplitude for B&amp;W pencil= float(60,0,200)
#@gimp : Amplitude for Soft glow = float(1,0,20)
bwpencil_glow :
  -gimp_pencilbw $1,$2,0,0,0
  -gimp_glow $3,0,0</pre>
<h4>2.3-Complex assembling</h4>
<p>Things become more complex when you have to deal with several images during the filter sequence that you want to assemble. It happens if you keep the original by setting the <code>Output mode</code> to <code>New layer</code> (or <code>New whatever</code>) or if one of your original filters creates several images (as <code>Layers &gt; Tiles to layers</code> or <code>Layers &gt; Split tones</code>). You can master that by just learning 2 easy more things from the G&#8217;mic language.</p>
<h5>2.3.1-Keeping the original</h5>
<p>So far, to call a G&#8217;mic command, you write a dash (-) followed by the command name, for example:</p>
<pre>  -gimp_pencilbw 0.3,60,0,0,0</pre>
<p>Well, if you put 2 dashes instead, G&#8217;mic processes the image the same way, but it also keeps the original. If you try the filter below, even if you set the <code>Output mode</code> to <code>In place</code>, you get your result in a new layer:</p>
<pre>#@gimp Keep BWpencil : keep_bwpencil, keep_bwpencil
keep_bwpencil :
  --gimp_pencilbw 0.3,60,0,0,0</pre>
<h5>2.3.2-Dealing with several images</h5>
<p>When it deals with multiple images, G&#8217;mic gives them numbers starting from 0. So in the previous example, your original image would be the number 0 and the <code>B&amp;W pencil</code> processed one would be the number 1.</p>
<p>If you don&#8217;t specify anything, by default, the next command apply to every images. For instance, in the next filter, <code>Soft glow</code> is applied to the original and to the <code>B&amp;W pencil</code> processed ones.</p>
<pre>#@gimp Keep BWpencil plus glow : keep_bwpencil_glow, keep_bwpencil_glow
keep_bwpencil_glow :
  --gimp_pencilbw 0.3,60,0,0,0
  -gimp_glow 1,0,0</pre>
<p>But, if you paste the image number into square brackets to your command name, then the process will apply only to the specified image. Thus, if you modify the previous filter as below, the glow is only performed on the <code>B&amp;W pencil</code> processed image, leaving the original untouched:</p>
<pre>#@gimp Keep BWpencil plus glow : keep_bwpencil_glow, keep_bwpencil_glow
keep_bwpencil_glow :
  --gimp_pencilbw 0.3,60,0,0,0
  -gimp_glow[1] 1,0,0</pre>
<p>You can ask to specifically process several images by adding numbers separated by a comma. To process the first, the third and the fifth one, you would paste [0,2,4] to the command name. There is <a href="http://zonderr.wordpress.com/2010/09/13/gmic-command-first-steps/#some_images">more</a> you might want to know about <a href="http://zonderr.wordpress.com/2011/02/18/about-the-image-stack/">that</a>.</p>
<h5>2.3.2-Let&#8217;s finish that</h5>
<p>This last filter seems so far unfinished to me, I feel that it could be useful to someone if the two layers obtained were composed together with some kind of <code>Layers Multiply</code> and if some tweaking possibilities was offered to the user. And since 2 filters were built during this tutorial, let&#8217;s place them both in the <code>.gmic</code> file, so that both can be used in the plug-in. The whole thing becomes then something like:</p>
<pre>#@gimp My first filter: my_first_filter_command, my_first_filter_command
#@gimp : note = note("It is my first filter, I am so excited!")
#@gimp : sep = separator()
#@gimp : Angle = float(45,0,360)
#@gimp : Fill the empty space = choice("in black","like the borders","by repeating the image")
my_first_filter_command :
  -rotate $1,$2

#@gimp Filter tutorial : filter_tuto, filter_tuto
#@gimp : Size = float(0.3,0,5)
#@gimp : Amplitude for B&amp;W pencil= float(60,0,200)
#@gimp : Amplitude for Soft glow = float(1,0,20)
filter_tuto :
  --gimp_pencilbw $1,$2,0,0,0
  -gimp_glow[1] $3,0,0
  -compose_multiply</pre>
<h4>2.4-Further</h4>
<p>Since this is programming, you are ought to meet some bugs. To debug, think about running gimp from the terminal and set the <code>Output messages</code> to <code>Verbose</code> or <code>Very verbose</code>. And don&#8217;t stay stuck alone, <a title="one active forum" href="http://www.flickr.com/groups/gmic/">get inspired, get help and share what you&#8217;ve made</a>.<br />
Once you&#8217;ll have played a bit, you might want to learn a <a title="Making better filters" href="http://zonderr.wordpress.com/2010/12/02/gmic-making-a-better-plug-in/">few more tricks for your filters</a>.</p>
<br />Filed under: <a href='http://zonderr.wordpress.com/category/en/'>en</a>, <a href='http://zonderr.wordpress.com/category/gmic/'>g'mic</a>, <a href='http://zonderr.wordpress.com/category/plugin/'>plugin</a> Tagged: <a href='http://zonderr.wordpress.com/tag/gmic/'>g'mic</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=223&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zonderr.wordpress.com/2010/11/13/howto-create-a-custom-filter-in-the-gmic-plug-in/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/5a21a09790b0a3dbcf83817a6388fdd5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zonderr</media:title>
		</media:content>
	</item>
		<item>
		<title>G’mic: Image et format</title>
		<link>http://zonderr.wordpress.com/2010/11/07/g%e2%80%99mic-image-et-format/</link>
		<comments>http://zonderr.wordpress.com/2010/11/07/g%e2%80%99mic-image-et-format/#comments</comments>
		<pubDate>Sun, 07 Nov 2010 11:13:25 +0000</pubDate>
		<dc:creator>zonderr</dc:creator>
				<category><![CDATA[fr]]></category>
		<category><![CDATA[g'mic]]></category>

		<guid isPermaLink="false">http://zonderr.wordpress.com/?p=191</guid>
		<description><![CDATA[0-Introduction Une image matricielle est matrice de pixels qui suit les règles de son format. Avec jusqu&#8217;à 4 canaux définissant la couleur d&#8217;après l&#8217;espace de couleur (RVB, CMJN, …) et des entiers de 0 à 255 ou à 65535, cela dépend du nombre de bits. Mais une fois que G&#8217;mic prend l&#8217;image en charge, elle <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=191&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>0-Introduction</h3>
<p>Une image matricielle est matrice de pixels qui suit les règles de son format. Avec jusqu&#8217;à 4 canaux définissant la couleur d&#8217;après l&#8217;espace de couleur (RVB, CMJN, …) et des entiers de 0 à 255 ou à 65535, cela dépend du nombre de bits.<br />
Mais une fois que G&#8217;mic prend l&#8217;image en charge, elle devient une matrice 4D de nombres à virgule sans réelle limitation. Cela signifie que durant la manipulation G&#8217;mic, vous pouvez avoir des nombres négatifs, des valeurs extrêmement hautes ou basses, des canaux par douzain, etc. Sensations de liberté&#8230;<br />
Mais vous aurez peut-être aussi parfois la sensation d&#8217;être perdu, parce que vous aurez des difficultés à faire rerentrer votre image dans le monde contraignant des formats d&#8217;image, à moins que vous ne soyez au courant de ce qui suit.</p>
<h3>1-Les canaux</h3>
<h4>1.1-Trois canaux dans le visionneur</h4>
<p>Le visionneur de G&#8217;mic n&#8217;est pas pensé pour l&#8217;affichage de l&#8217;image, mais pour l&#8217;affichage d&#8217;informations de cette matrice 4D. Il ne montre que les 3 premiers canaux et considère que l&#8217;image est en RVB. Donc, si vous manipulez une image en CMJN, le canal N est ignoré et le reste aura l&#8217;air plutôt étrange. Si vous chargez une image avec transparence, vous ne la verrez pas.<br />
Vous pouvez visualiser le quatrième canal en utilisant, par exemple, la commande <em>-channels</em>:</p>
<pre>gmic mon_image.jpg -channels 3</pre>
<p>Vous pouvez aussi demander à G&#8217;mic de simuler la transparence du quatrième canal sous forme de damier:</p>
<pre>gmic mon_image.jpg -display_rgba</pre>
<h4>1.2-Combien de canaux dans quel format?</h4>
<p>La façon dont vous arriverez à faire rentrer tous les canaux dans le fichier que vous avez l&#8217;intention de créer dépend du format d&#8217;image utilisé. G&#8217;mic tente de placer autant de canaux que le format peut en contenir et fait disparaître les autres. Et la signification des différents canaux dépend du format utilisé. Par exemple, 4 canaux dans un JPEG sera interprété comme une image CMJN alors que 4 canaux dans un PNG constituera un RGBA. Pour être sûr de ce que vous obtenez finalement, utilisez un visionneur « conventionnel » ou utilisez <a href="http://www.imagemagick.org">ImageMagick</a>:</p>
<pre>identify -verbose mon_image.jpg |grep Colorspace</pre>
<p style="text-align:center;"><a href="http://zonderr.files.wordpress.com/2010/10/tux_rgb.png"><img class="aligncenter size-medium wp-image-142" title="Les 3 canaux de Tux Crystal" src="http://zonderr.files.wordpress.com/2010/10/tux_rgb.png?w=300&#038;h=100" alt="alternate" width="300" height="100" /></a></p>
<p style="text-align:center;">récupérez <a href="http://fr.wikipedia.org/wiki/Fichier:Crystal_128_penguin.png">Tux</a> avec <em>gmic tux_rgb.png -split x,3 -+</em>, <a href="http://www.gnu.org/licenses/lgpl.html">LGPL</a></p>
<h3>2-Les nombres</h3>
<h4>2.1-Montrer n&#8217;importe quel nombre</h4>
<p>Puisque virtuellement, n&#8217;importe quel nombre peut être contenu dans la matrice, le visionneur G&#8217;mic gère ce point en considérant le plus grand nombre comme le plus lumineux et le plus petit comme le plus sombre, puis il étire linéairement ce qu&#8217;il reste entre les 2. Il faut donc faire attention quand vous utilisez des algorithmes qui retournent des valeurs non conventionnelles. Par exemple:</p>
<pre>gmic mon_image.jpg -luminance -threshold 120</pre>
<p>affichera une image en noir et blanc, mais comme la commande <em>-threshold</em> ne retourne que des 0 ou des 1, si vous exportez ça dans un format conventionnel, vous obtiendrez une image très foncée. Ça se gère habituellement en étirant les valeurs entre 0 et 255 avec <em>-normalize</em>:</p>
<pre>gmic mon_image.jpg -luminance -threshold 120 -normalize 0,255</pre>
<p>D&#8217;autres manipulations peuvent localement introduire des valeurs extrêmes. Si vous faites:</p>
<pre>gmic mon_image.jpg -unsharp_octave 2,2</pre>
<p>Vous obtiendrez des valeurs comme -250 ou 450 sur un très faible nombre de pixels, votre image apparaîtra donc bien grise dans le visionneur G&#8217;mic. Rasez tout ça avec <em>-cut</em>:</p>
<pre>gmic mon_image.jpg -unsharp_octave 2,2 -cut 0,255</pre>
<p>Encore un commentaire sur le sujet, il est possible d&#8217;éviter l&#8217;étirement des valeurs dans le visionneur G&#8217;mic: <em>-display0</em>.</p>
<h4>2.2-Ce que ça devient dans le fichier</h4>
<p>Si toutes les valeurs sont contenues dans l&#8217;intervalle [0,255], G&#8217;mic se contentera d&#8217;arrondir à l&#8217;entier le plus proche et produira une image 8 bits. Mais si une seule valeur sort de ces limites, il produira une image 16 bits si le format le permet et/ou transformera les mauvaises valeurs en brouillard parasite afin que ça rentre dans les limites. ImageMagick peut vous aider à savoir ce qu&#8217;il s&#8217;est passé:</p>
<pre>identify -verbose mon_image.jpg |grep bit</pre>
<p style="text-align:center;"><a href="http://zonderr.files.wordpress.com/2010/10/fear_heads.jpg"><img class="aligncenter size-medium wp-image-147" title="N'oubliez pas -cut 0,255" src="http://zonderr.files.wordpress.com/2010/10/fear_heads.jpg?w=500&#038;h=114" alt="" width="500" height="114" /></a></p>
<p style="text-align:center;">A partir de <strong> <a href="http://www.flickr.com/photos/troyholden/4025623939/">Troy Holden</a></strong>, <a href="http://creativecommons.org/licenses/by-nc-nd/2.0/">CC-by-nc-nd</a></p>
<h3>3-Encore quelques petites choses à propos de formats</h3>
<h4>3.1-A propos de Tiff</h4>
<p>Le format TIFF est supposé accepter les nombres réels, donc G&#8217;mic n&#8217;hésite pas à les en mettre dedans. Mais en pratique, il est difficile de trouver un visionneur capable de lire de tels TIFF. Pour éviter les soucis de ce genre, vous devriez ajouter <em>-type uchar</em> avant d&#8217;exporter en TIFF. La commande précédente deviendrait:</p>
<pre>gmic mon_image.jpg -unsharp_octave 2,2 -type uchar -o mon_image.tiff</pre>
<h4>3.2-About Raw</h4>
<p>G&#8217;mic sait gérer le raw, mais vous devez faire attention au type et aux dimensions vous-même. Par exemple, pour charger une image 8 bit de dimension 1000x1000x200, utilisez la commande:</p>
<pre>gmic -type uchar mon_image.raw,1000,1000,200</pre>
<h4>3.3-Formats natifs: CIMG et CIMGZ</h4>
<p>Les formats natifs de G&#8217;mic sont le CIMG et son analogue compressé, le CIMGZ. Donc, si vous avez besoin de stocker votre image au cours d&#8217;une manipulation, il est conseillé de le faire dans l&#8217;un de ces formats pour éviter de perdre des informations à travers les contraintes habituelles. Ex:</p>
<pre>gmic mon_image.jpg -unsharp_octave 2,2 -o mon_image.cimg</pre>
<pre>gmic mon_image.jpg -unsharp_octave 2,2 -o mon_image.cimgz</pre>
<h4>3.4-Formats texte</h4>
<p>Una autre façon de conserver toutes les informations est d&#8217;utiliser un format texte (TXT ou DLM). De cette façon, vous serez même capable d&#8217;utiliser un éditeur de texte pour modifier votre image:</p>
<pre>gmic mon_image.jpg -unsharp_octave 2,2 -o mon_image.txt</pre>
<pre>gmic mon_image.jpg -unsharp_octave 2,2 -o mon_image.dlm</pre>
<h4>3.5-Entrée/sortie standard</h4>
<p>Vous pouvez aussi lire à partir de l&#8217;entrée standard ou écrire sur la sortie standard. Les  deux commandes ci-dessous sont identiques. Elle demandent à G&#8217;mic de lire l&#8217;entrée standard au format texte:</p>
<pre>echo -e "1 2 3\n4 5 6" | gmic -.txt
echo -e "1 2 3\n4 5 6" | gmic txt:-</pre>
<p>Les deux commandes ci-dessous écrivent sur la sortie standard au format texte:</p>
<pre>gmic image.jpg -o -.txt
gmic image.jpg -o txt:-</pre>
<br />Filed under: <a href='http://zonderr.wordpress.com/category/fr/'>fr</a>, <a href='http://zonderr.wordpress.com/category/gmic/'>g'mic</a> Tagged: <a href='http://zonderr.wordpress.com/tag/gmic/'>g'mic</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=191&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zonderr.wordpress.com/2010/11/07/g%e2%80%99mic-image-et-format/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/5a21a09790b0a3dbcf83817a6388fdd5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zonderr</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2010/10/tux_rgb.png?w=300" medium="image">
			<media:title type="html">Les 3 canaux de Tux Crystal</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2010/10/fear_heads.jpg?w=500" medium="image">
			<media:title type="html">N&#039;oubliez pas -cut 0,255</media:title>
		</media:content>
	</item>
		<item>
		<title>Initiation au langage G&#8217;mic</title>
		<link>http://zonderr.wordpress.com/2010/10/09/initiation-au-langage-gmic/</link>
		<comments>http://zonderr.wordpress.com/2010/10/09/initiation-au-langage-gmic/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 09:45:45 +0000</pubDate>
		<dc:creator>zonderr</dc:creator>
				<category><![CDATA[fr]]></category>
		<category><![CDATA[g'mic]]></category>

		<guid isPermaLink="false">http://zonderr.wordpress.com/?p=150</guid>
		<description><![CDATA[0-Introduction dispensable Avant d&#8217;être un populaire greffon pour Gimp, G&#8217;mic est un logiciel en ligne de commande dédié au traitement d&#8217;images. Ce tutoriel suppose que les lignes de commande sont tapées dans un terminal Unix. Les utilisateurs de Windows devront s&#8217;adapter et voudront peut-être installer MinGW. Il est aussi possible de tester les notions développées <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=150&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>0-Introduction dispensable</h3>
<p>Avant d&#8217;être un populaire greffon pour <a id="zrw3" title="Gimp plugin" href="http://gmic.sourceforge.net/gimp.shtml">Gimp</a>, <a href="http://gmic.sourceforge.net/">G&#8217;mic</a> est un logiciel en ligne de commande dédié au traitement d&#8217;images. Ce tutoriel suppose que les lignes de commande sont tapées dans un terminal Unix. Les utilisateurs de Windows devront s&#8217;adapter et voudront peut-être installer <a id="g_q6" title="MinGW" href="http://www.mingw.org">MinGW</a>. Il est aussi possible de tester les notions développées ici dans un <a title="Howto create a custom filter in the G'mic plug-in" href="http://zonderr.wordpress.com/2010/11/13/howto-create-a-custom-filter-in-the-gmic-plug-in/">filtre prévu pour le greffon</a>.</p>
<div>Toutes les lignes de commande G&#8217;mic ressemblent formellement à :&nbsp;</p>
<pre>gmic -instruction1 arguments -instruction2 arguments etc...</pre>
<p>Tout est déjà expliqué dans la  <a id="f0gv" title="official documentation page" href="http://gmic.sourceforge.net/reference.shtml">page de référence officielle</a>, mais ça vous semblera surement trop aride là-bas, pour un peu de luxuriance, voyez ci-dessous.</p>
<h3>1-Exemple de base</h3>
<p>Avant d&#8217;appliquer un traitement à une image, G&#8217;mic doit la charger avec l&#8217;instruction <em>-input</em>. Après le traitement, vous voudrez probablement décharger le résultat final sur votre disque dur en utilisant l&#8217;instruction <em>-output</em>.</p>
<p>Prenons un exemple de base. Pour faire tourner de 90° une image appelée <em>image.jpg</em> et sauver le résultat en tant que fichier au format PNG, vous utiliserez la commande:</p>
<pre>gmic -input image.jpg -rotate 90 -output image.png</pre>
<p>Vous remarquerez que G&#8217;mic retourne le détail des opérations dans le terminal. Pour la ligne de commande précédente, vous devriez avoir quelque chose comme ça:</p>
<pre>[gmic]-0./ Start G'MIC instance.
[gmic]-0./ Input file 'image.jpg' at position [0] (1 image 512x384x1x3).
[gmic]-1./ Rotate image [0] of 90 deg., black borders and linear interpolation.
[gmic]-1./ Output image [0] as file 'image.png'.
[gmic]-1./ End G'MIC instance.</pre>
<p>Comme ça, vous ne pourrez pas dire que vous ne savez pas ce qu&#8217;il se passe.</p>
<p style="text-align:center;">&nbsp;</p>
<h4><a href="http://zonderr.files.wordpress.com/2010/09/rouge2.png"><img class="aligncenter size-medium wp-image-19" title="Please rotate" src="http://zonderr.files.wordpress.com/2010/09/rouge2.png?w=300&#038;h=288" alt="" width="300" height="288" /></a></h4>
<p style="text-align:center;"><a href="http://www.flickr.com/photos/rantz/4537655964">De Rantz</a>, <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">CC-by-nc-sa</a></p>
<h3>2-Les alias</h3>
<p>Pour faciliter les choses, les instructions les plus courantes ont des alias. Par exemple, <em>-input</em> peut être remplacé par<em> -i </em>et <em>-output </em>par <em>-o</em>. Ainsi, notre exemple de base peut être réécrit:</p>
<pre>gmic -i image.jpg -rotate 90 -o image.png</pre>
<p>En fait, l&#8217;instruction <em>-input</em> est tellement courante qu&#8217;une façon encore plus rapide de l&#8217;invoquer est implémentée dans G&#8217;mic: il suffit de taper directement le nom de l&#8217;image sans aucune instruction. La ligne de commande suivante est donc l&#8217;exacte équivalente de la précédente:</p>
<pre>gmic image.jpg -rotate 90 -o image.png</pre>
<p>N&#8217;en espérez pas plus, ça n&#8217;ira pas plus vite.</p>
<h3>3-Détails à propos de <em>-output</em></h3>
<h4>3.1-Formats</h4>
<p>vous pouvez sauver l&#8217;image que vous traitez n&#8217;importe où dans la ligne de commande (avant ou après une opération) et le nom du fichier de sortie détermine le format. Ainsi, avec la ligne de commande suivante, vous obtenez 3 images dans 3 différents formats, la BMP n&#8217;a pas subi de rotation alors que les autres, si.</p>
<pre>gmic image.jpg -o image.bmp -rotate 90 -o image.png -o image.tga</pre>
<p>A propos, par défaut, G&#8217;mic sauvegarde les fichiers JPEG avec la qualité 100, ce qui est probablement plus que ce que vous souhaiteriez. Pour sauvegardez en qualité 95, utilisez <em>-o image.jpg,95</em></p>
<h4>3.2-Affichage</h4>
<p>Si vous ne spécifiez aucune instruction <em>-output</em> (ou <em>-o</em>) ou si vous donnez explicitement l&#8217;instruction <em>-display</em>, alors G&#8217;mic affichera votre image sur l&#8217;écran. Les 2 prochaines lignes de commandes font la même chose: elles affichent l&#8217;image après avoir fait une rotation de 45°.</p>
<pre>gmic image.jpg -rotate 45
gmic image.jpg -rotate 45 -display</pre>
<p>Tapez &#8216;q&#8217; pour quitter l&#8217;écran d&#8217;affichage.</p>
<p>Il y a encore beaucoup à dire sur l&#8217;écran d&#8217;affichage, mais ce ne sera <a href="http://zonderr.wordpress.com/2010/11/07/g%E2%80%99mic-image-et-format/">pas pour maintenant</a>.</p>
</div>
<h3>4-Les arguments de l&#8217;instruction</h3>
<p>Depuis le début, l&#8217;image effectue des rotations, uniquement des rotations. Mais comme la plupart des instructions G&#8217;mic, l&#8217;instruction <em>-rotate</em> possède de nombreux arguments afin de spécifier la façon dont doit se passer cette la rotation. Si vous regardez, la <a id="d7qb" title="documentation officielle" href="http://gmic.sourceforge.net/reference.shtml">page de documentation officielle</a>, vous trouverez la ligne expliquant comment <em>-rotate </em>fonctionne. Ça commence par:</p>
<div>
<p style="padding-left:30px;"><strong><span style="color:green;">-rotate </span></strong> angle,_borders,_interpolation,_cx[%],_cy[%],_zoom</p>
<p>Cela signifie que <em>-rotate</em> peut avoir jusqu&#8217;à 6 arguments. Le premier (angle) doit être spécifié. Les autres commencent par un soulignement ( _ ), cela veut dire qu&#8217;ils sont optionnels. Quelques tests devraient suffire à vous faire comprendre le fonctionnement. Essayez ces lignes par exemple:</p>
<pre>gmic image.jpg -rotate 30,1
gmic image.jpg -rotate 30,0,0,50%,50%
gmic image.jpg -rotate 30,0,0,0%,0%,0.5</pre>
<p>Vous pouvez aussi obtenir la documentation officielle hors connexion avec <em>man gmic </em>ou <em>gmic -h</em>.</p>
</div>
<h3>5-Gestion de plusieurs images</h3>
<h4>5.1-Toutes comme une</h4>
<div>
<p>Vous pouvez gérer plusieurs images à la fois, il suffit de toutes les charger. Par exemple, les lignes suivantes chargent les images et les affichent:</p>
<pre>gmic image1.jpg image2.jpg image3.jpg
gmic image*.jpg</pre>
<p>Si vous écrivez votre ligne de commande comme dans le chapitre précédent, les instructions G&#8217;mic seront alors appliquées à toutes les images chargées. En lançant la ligne suivante:</p>
<pre>gmic image*.jpg -rotate 90 -o image.png</pre>
<p>Vous ordonnez à G&#8217;mic d&#8217;appliquer une rotation à tous les fichiers <em>image*.jpg</em> et de les sauver en tant que PNG. Mais il ne sauvera pas plusieurs images dans un seul fichier appelé <em>image.png</em>, il les nommera <em>image_000001.png, image_000002.png, image_000003.png</em>, etc.</p>
</div>
<h4 id="some_images">5.2-Restreindre l&#8217;instruction à seulement quelques images</h4>
<div>
<p>Vous pouvez spécifier les images sur lesquelles vous voulez appliquer une instruction en ajoutant le numéro de l&#8217;image, en commençant par 0, entre crochets:</p>
<pre>gmic image*.jpg -rotate[0] 90</pre>
<p>n&#8217;effectue la rotation que sur la première image chargée.</p>
<pre>gmic image*.jpg -o[1] image.png</pre>
<p>sauvegarde seulement la deuxième en tant que <em>image.png</em>.</p>
<p>Si vous utilisez des nombres négatifs, vous commencez par la dernière image:</p>
<pre>gmic image*.jpg -rotate[-1] 90</pre>
<p>n&#8217;effectue la rotation que sur la dernière image chargée.</p>
<pre>gmic image*.jpg -rotate[-2] 90</pre>
<p>n&#8217;effectue la rotation que sur l&#8217;avant-dernière.</p>
<p>Vous pouvez aussi sélectionner un jeu d&#8217;image à manipuler:</p>
<div>
<table id="mp6i" class="zeroBorder" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[0,2,-1] 90</code></td>
<td>tourne la première, la troisième et la dernière.</td>
</tr>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[0-9] 90</code></td>
<td>tourne les 10 premières images.</td>
</tr>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[0-10:3] 90</code></td>
<td>tourne une image sur 3 en commençant par la première et finissant par la onzième, i.e. la première, la quatrième, la septième et la dixième.</td>
</tr>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[0,-4--1] 90</code></td>
<td>tourne la première et les 4 dernières.</td>
</tr>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[50%-100%] 90</code></td>
<td>tourne la seconde moitié de la liste d&#8217;images.</td>
</tr>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[0,50%--1]  90</code></td>
<td>tourne la première image et la seconde moitié de la liste d&#8217;images.</td>
</tr>
</tbody>
</table>
</div>
</div>
<h4><a href="http://zonderr.files.wordpress.com/2010/09/foret_petite2.png"><img class="aligncenter size-medium wp-image-19" title="C'est clair?" src="http://zonderr.files.wordpress.com/2010/09/foret_petite2.png?w=300&#038;h=288" alt="" width="300" height="288" /></a></h4>
<p style="text-align:center;"><a href="http://www.flickr.com/photos/rantz/4525158916">Modifié de Rantz</a>, <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">CC-by-nc-sa</a></p>
<h4>5.3-Conserver l&#8217;original</h4>
<p>Par défaut, une instruction remplace l&#8217;image originale by celle manipulée. il y a une façon de conserver l&#8217;originale: utiliser le double tiret (- -). Ex:</p>
<pre>gmic image.jpg --rotate 90</pre>
<p>produit 2 images: image.jpg et image.jpg tournée de 90°. Plus de détails sont disponibles <a href="http://zonderr.wordpress.com/2011/02/18/about-the-image-stack/">ici</a>.</p>
<h4>5.4-Manipuler la liste d&#8217;images</h4>
<div>
<p>Comme vous l&#8217;avez vu dans le chapitre précédent, l&#8217;ordre des images est important. Vous pouvez modifier cet ordre quand bon vous semble en utilisant <em>-move </em>or <em>-reverse:</em></p>
<pre>gmic image*.jpg -move[50%-100%] 0</pre>
<p>déplace la deuxième moitié des images au début.</p>
<pre>gmic image*.jpg -reverse</pre>
<p>inverse l&#8217;ordre de toutes les images.<br />
Vous pouvez aussi ne conserver qu&#8217;une partie des images de votre liste avec <em>-keep</em> ou vous débarrasser de certaines avec <em>-remove</em>. Si vous vous sentez perdu parfois, regardez ce que G&#8217;mic retourne dans le terminal, il devrait signaler combien d&#8217;images il reste.</p>
<h3>6-Les commandes personnalisées</h3>
<p>Quand vous commencez à jouer sérieusement avec G&#8217;mic, les lignes de commandes peuvent devenir bien longue. Une solution élégante consiste en l&#8217;écriture d&#8217;une commande personnalisée. De nombreuses commandes personnalisées existent déjà, vous pouvez les étudier et beaucoup apprendre <a id="m11b" title="gmic_def.gmic" href="http://cimg.cvs.sourceforge.net/viewvc/cimg/CImg/examples/gmic_def.gmic">à travers elles</a>.</p>
<p>Ça vous aiderait probablement d&#8217;avoir un peu plus d&#8217;explications sur l&#8217;art d&#8217;écrire des commandes personnalisées, mais vous n&#8217;en trouverez pas ici. Tout ce qui sera dit est qu&#8217;il vous faut charger votre commande personnalisée avant de pouvoir l&#8217;utiliser.</p>
<p>Cela se fait en utilisant l&#8217;instruction <em>-command</em> ou <em>-m</em> ou encore sans instruction du tout si votre fichier finit par <em>.gmic</em>. Ainsi, les 3 prochaines lignes de commandes font la même chose:</p>
<pre>gmic -command mon_fichier_de_commande_personnalisee.gmic image.jpg -my_command
gmic -m mon_fichier_de_commande_personnalisee.gmic image.jpg -my_command
gmic mon_fichier_de_commande_personnalisee.gmic image.jpg -my_command</pre>
</div>
<h3>7-Aller plus loin</h3>
<p>Pour aller plus loin, il peut sembler logique de consulter <a href="http://zonderr.wordpress.com/2010/11/07/g%E2%80%99mic-image-et-format/">cet article</a>. Puis, pour augmenter votre culture G&#8217;mic, vous devriez sans doute cliquer sur <a id="hau4" title="gallery's images" href="http://gmic.sourceforge.net/gallery.shtml">les images de la galerie</a> et pour maitriser la technique, n&#8217;oubliez pas <a id="y4ra" title="custom command file" href="http://cimg.cvs.sourceforge.net/viewvc/cimg/CImg/examples/gmic_def.gmic">le fichier de commandes personnalisées</a>.<br />
Vous êtes aussi invités à partager vos problèmes et vos solutions au <a href="http://www.flickr.com/groups/gmic">forum</a>(en).</p>
<p><a href="http://www.flickr.com/photos/rantz/4525158916"><img class="aligncenter" title="Twisted Traveling, De Rantz CC-BY-NC-SA" src="http://farm5.static.flickr.com/4023/4525158916_04b169a8a5.jpg" alt="" width="400" height="400" /></a></p>
<p style="text-align:center;"><a href="http://www.flickr.com/photos/rantz/4525158916">De Rantz</a>, <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">CC-by-nc-sa</a></p>
<br />Filed under: <a href='http://zonderr.wordpress.com/category/fr/'>fr</a>, <a href='http://zonderr.wordpress.com/category/gmic/'>g'mic</a> Tagged: <a href='http://zonderr.wordpress.com/tag/gmic/'>g'mic</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=150&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zonderr.wordpress.com/2010/10/09/initiation-au-langage-gmic/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/5a21a09790b0a3dbcf83817a6388fdd5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zonderr</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2010/09/rouge2.png" medium="image">
			<media:title type="html">Please rotate</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2010/09/foret_petite2.png?w=300" medium="image">
			<media:title type="html">C&#039;est clair?</media:title>
		</media:content>

		<media:content url="http://farm5.static.flickr.com/4023/4525158916_04b169a8a5.jpg" medium="image">
			<media:title type="html">Twisted Traveling, De Rantz CC-BY-NC-SA</media:title>
		</media:content>
	</item>
		<item>
		<title>G’mic: Image and format</title>
		<link>http://zonderr.wordpress.com/2010/10/06/gmic-image-and-format/</link>
		<comments>http://zonderr.wordpress.com/2010/10/06/gmic-image-and-format/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 19:59:36 +0000</pubDate>
		<dc:creator>zonderr</dc:creator>
				<category><![CDATA[en]]></category>
		<category><![CDATA[g'mic]]></category>

		<guid isPermaLink="false">http://zonderr.wordpress.com/?p=90</guid>
		<description><![CDATA[0-Irrelevant introduction A raster image is a pixel matrix, that follows its format rules, with up to 4 channels setting the color according to the colorspace (RGB, CMYK, …) and with integers from 0 to 255 or to 65535, it depends on the number of bits. But once an image enter G’mic, it becomes a <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=90&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>0-Irrelevant introduction</h3>
<p>A raster image is a pixel matrix, that follows its format rules, with up to 4 channels setting the color according to the colorspace (RGB, CMYK, …) and with integers from 0 to 255 or to 65535, it depends on the number of bits.</p>
<p>But once an image enter G’mic, it becomes a 4D floating-point number matrix with no real limitation. It means that during the G’mic process, you can have negative numbers, extremely high or low values, dozens of channels… feel the freedom.</p>
<p>And then you might feel lost, because you might have difficulties to have your picture reenter the constrained world of image formats, unless you are aware of what is said below.</p>
<h3>1-Channels</h3>
<h4>1.1-Three channels in the viewer</h4>
<p>The G’mic viewer isn’t meant to show the picture, it is meant to show information about this 4D matrix. It only shows the 3 first channels and considers them as RGB. So, if you play with a CMYK picture, the K value will be ignored and the rest will look weird. If you had loaded an image with transparency, you would not see it. You can visualize the fourth channel using, for example, the <em>-channels</em> command:</p>
<pre>gmic my_image.jpg -channels 3</pre>
<p>You can also specifically ask the viewer to mimic transparency for the fourth channel by adding some checker board:</p>
<pre>gmic my_image.jpg -display_rgba</pre>
<h4>1.2-How many channels in that format?</h4>
<p>The way all your channels fits in the file you intend to create depends on the format used. G’mic tries to fit as many channels as the format accepts and discard the others and what means the channels that fit depends on the format. For example, 4 channels into a JPEG are understood as a CMYK file whereas 4 inside a PNG are understood as RGBA. To be sure of what you finally get, use a « conventional » viewer or use <a href="http://www.imagemagick.org">ImageMagick</a>:</p>
<pre>identify -verbose my_image.jpg |grep Colorspace</pre>
<p style="text-align:center;"><a href="http://zonderr.files.wordpress.com/2010/10/tux_rgb.png"><img class="aligncenter size-medium wp-image-142" title="The 3 channels of Tux Crystal" src="http://zonderr.files.wordpress.com/2010/10/tux_rgb.png?w=300&#038;h=100" alt="alternate" width="300" height="100" /></a></p>
<p style="text-align:center;">get <a href="http://fr.wikipedia.org/wiki/Fichier:Crystal_128_penguin.png">Tux</a> back with <em>gmic tux_rgb.png -split x,3 -+</em>, <a href="http://www.gnu.org/licenses/lgpl.html">LGPL</a></p>
<h3>2-Numbers</h3>
<h4>2.1-Show any number</h4>
<p>Since virtually any number can be contained in the matrix, the G’mic viewer is dealing with that by considering the highest value as the brightest and the lowest one  as the darkest and by stretching linearly all the rest  in between. So be careful when you use algorithms that return unconventional values. For instance:</p>
<pre>gmic my_image.jpg -luminance -threshold 120</pre>
<p>will display a black and white picture, but since the <em>-threshold</em> command returns only 1 or 0, if you output that in any conventional image format, you’ll get a pretty dark image. The usual way to circumvent this is to stretch values from 0 to 255 with <em>-normalize</em>:</p>
<pre>gmic my_image.jpg -luminance -threshold 120 -normalize 0,255</pre>
<p>Some other processing might introduce localized extreme values. If you do:</p>
<pre>gmic my_image.jpg -unsharp_octave 2,2</pre>
<p>You’ll get values such as -250 or 450 in very few pixels, your image will thus appear quite gray in the G’mic viewer. Shave this with <em>-cut</em>:</p>
<pre>gmic my_image.jpg -unsharp_octave 2,2 -cut 0,255</pre>
<p>Last comment on this, there is a way to avoid G’mic viewer stretching: <em>-display0</em>.</p>
<h4>2.2-What it becomes in the file</h4>
<p>If everything belongs to the [0,255] interval, then G’mic will just round all that to get integers and produce an 8 bit image. But if any number exits these limits, it will produce a 16 bit image if the format allows it and/or transform wrong numbers in garbage to fit into the limits. ImageMagick can tell you what happened:</p>
<pre>identify -verbose my_image.jpg |grep bit</pre>
<p style="text-align:center;"><a href="http://zonderr.files.wordpress.com/2010/10/fear_heads.jpg"><img class="aligncenter size-medium wp-image-147" title="Don't forget to -cut 0,255" src="http://zonderr.files.wordpress.com/2010/10/fear_heads.jpg?w=500&#038;h=114" alt="" width="500" height="114" /></a></p>
<p style="text-align:center;">From<strong> <a href="http://www.flickr.com/photos/troyholden/4025623939/">Troy Holden</a></strong>, <a href="http://creativecommons.org/licenses/by-nc-nd/2.0/">CC-by-nc-nd</a></p>
<h3>3-A few other things about formats</h3>
<h4>3.1-About Tiff</h4>
<p>The TIFF format is supposed to accept floating point numbers, so G’mic doesn’t hesitate to stuff them in it. But in practice, it is difficult to find a viewer that can read such TIFF. To avoid issues about it, you should add<em> -type uchar</em> before outputing. The previous example would become:</p>
<pre>gmic my_image.jpg -unsharp_octave 2,2 -type uchar -o my_image.tiff</pre>
<h4>3.2-About Raw</h4>
<p>G&#8217;mic is able to deal with raw format, but you should take care of type and image dimensions yourself. For example, to load an 8 bit with dimensions 1000x1000x200, you would do:</p>
<pre>gmic -type uchar my_image.raw,1000,1000,200</pre>
<h4>3.3-Native formats: CIMG and CIMGZ</h4>
<p>The native G’mic format is CIMG and its analogous compressed CIMGZ. So, if you need to store your image in a middle of a process, it is advised to store it in one of these formats to avoid loosing information via usual formats constraints. Ex:</p>
<pre>gmic my_image.jpg -unsharp_octave 2,2 -o my_image.cimg</pre>
<pre>gmic my_image.jpg -unsharp_octave 2,2 -o my_image.cimgz</pre>
<h4>3.4-Text formats</h4>
<p>Another way to keep all informations is to use a text format (TXT or DLM). This way, you will even be able to use text editor to modify your picture:</p>
<pre>gmic my_image.jpg -unsharp_octave 2,2 -o my_image.txt</pre>
<pre>gmic my_image.jpg -unsharp_octave 2,2 -o my_image.dlm</pre>
<h4>3.5-Standard input/output</h4>
<p>You can also read from the standard input or write to the standard output. Both commands below are identical.  They tell G&#8217;mic to read from the standard input in text format:</p>
<pre>echo -e "1 2 3\n4 5 6" | gmic -.txt
echo -e "1 2 3\n4 5 6" | gmic txt:-</pre>
<p>To tell G&#8217;mic to write an image to the standard output in text format, it would one of those:</p>
<pre>gmic image.jpg -o -.txt
gmic image.jpg -o txt:-</pre>
<br />Filed under: <a href='http://zonderr.wordpress.com/category/en/'>en</a>, <a href='http://zonderr.wordpress.com/category/gmic/'>g'mic</a> Tagged: <a href='http://zonderr.wordpress.com/tag/gmic/'>g'mic</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=90&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zonderr.wordpress.com/2010/10/06/gmic-image-and-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/5a21a09790b0a3dbcf83817a6388fdd5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zonderr</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2010/10/tux_rgb.png?w=300" medium="image">
			<media:title type="html">The 3 channels of Tux Crystal</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2010/10/fear_heads.jpg?w=500" medium="image">
			<media:title type="html">Don&#039;t forget to -cut 0,255</media:title>
		</media:content>
	</item>
		<item>
		<title>G’mic: The command line behind the Gimp plug-in</title>
		<link>http://zonderr.wordpress.com/2010/09/18/gmic-from-the-gimp-plugin-to-the-command-line/</link>
		<comments>http://zonderr.wordpress.com/2010/09/18/gmic-from-the-gimp-plugin-to-the-command-line/#comments</comments>
		<pubDate>Sat, 18 Sep 2010 20:13:05 +0000</pubDate>
		<dc:creator>zonderr</dc:creator>
				<category><![CDATA[en]]></category>
		<category><![CDATA[g'mic]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://zonderr.wordpress.com/?p=3</guid>
		<description><![CDATA[0-Expendable introduction The G&#8217;mic plug-in for Gimp is based on the G&#8217;mic language. Each filter proposed in the plug-in corresponds to a G&#8217;mic command line, each setting is just a parameter of that command line. And command lines are great because : it is a way to remember settings and filter sequences, it allows to <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=3&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>0-Expendable introduction</h3>
<p>The G&#8217;mic plug-in for Gimp is based on the <a href="http://gmic.sourceforge.net/">G&#8217;mic</a> language. Each filter proposed in the plug-in corresponds to a G&#8217;mic command line, each setting is just a parameter of that command line. And command lines are great because :</p>
<ol>
<li>it is a way to remember settings and filter sequences,</li>
<li>it allows to (almost) effortlessly apply on a large set of images what you just did graphically.</li>
</ol>
<p>Anything said below supposes that you run some kind of linux, but the spirit of it apply under other OS too.</p>
<h3>1-How to get the command lines?</h3>
<p>To have the plug-in tells you what you do graphically in the command line language, you just have to start Gimp from a terminal and to set it to &#8220;verbose mode&#8221;.</p>
<p>To start from a terminal, just open a terminal and type :</p>
<pre>gimp</pre>
<p>To set it to &#8220;verbose mode&#8221;, once you have open the plug-in, set the &#8220;ouput messages&#8230;&#8221; menu on the left to &#8220;Verbose&#8221;.</p>
<p>From now on, you&#8217;ll see text appearing in the terminal each time G&#8217;mic adapt the preview to your new setting and each time you apply a filter on your image.</p>
<p style="text-align:center;"><a class="align center" href="http://zonderr.files.wordpress.com/2010/09/capture.png"><img class="size-medium wp-image-49  " title="Here! down left!" src="http://zonderr.files.wordpress.com/2010/09/capture.png?w=300&#038;h=145" alt="" width="300" height="145" /></a><br />
<a href="http://www.flickr.com/photos/photocomix-mandala/4847547894">Image from PhotoComiX</a>, <a href="http://creativecommons.org/licenses/by-nc/3.0/">CC-by-nc</a></p>
<h3>2-What it looks like?</h3>
<p>Two kind of lines appear in the terminal. The ones telling what command is used to create the preview (containing the <code>/preview/</code> sequence) and the ones telling what command is really applied on the picture (containing the <code>/apply/</code> sequence). You are probably only interested in the last kind.</p>
<p>For example, the line:</p>
<pre>[gmic_gimp]./apply/ -v -99 -gimp_mix_rgb 1,0,0,1,0,0,1,0,0,0,2,0</pre>
<p>tells that the command called was <code>gimp_mix_rgb</code> and all the numbers behind correspond to the settings.</p>
<h3>3-What to do with it?</h3>
<p>You could just be happy to know what happens and to be able to keep everything in a text file with a simple copy/paste, but you could also want to apply it in a terminal. Just go to the directory where your file (say <code>image.jpg</code>) is and type:</p>
<pre>gmic image.jpg -gimp_mix_rgb 1,0,0,1,0,0,1,0,8.5,0,2,0</pre>
<p>Your processed image will be displayed, but not saved.<br />
To save it instead of displaying it:</p>
<pre>gmic image.jpg -gimp_mix_rgb 1,0,0,1,0,0,1,0,8.5,0,2,0 -o processed_image.jpg</pre>
<p>If you have many images (whose names finish by <code>jpg</code>) that you want to be processed, a script like that should do it:</p>
<pre>for i in *jpg
do
gmic $i -gimp_mix_rgb 1,0,0,1,0,0,1,0,8.5,0,2,0 -o processed_$i
done</pre>
<p><a href="http://zonderr.files.wordpress.com/2010/09/utilities-terminal.png"><img class="aligncenter size-full wp-image-83" title="Utilities-terminal" src="http://zonderr.files.wordpress.com/2010/09/utilities-terminal.png?w=510" alt=""   /></a></p>
<p style="text-align:center;"><a href="http://commons.wikimedia.org/wiki/File:Utilities-terminal.svg">Image Wikimedia</a></p>
<h3>4-By the way</h3>
<p>If you only want the &#8220;interested&#8221; lines to appear in your terminal, you should run Gimp with this command instead:</p>
<pre>gimp |grep apply</pre>
<br />Filed under: <a href='http://zonderr.wordpress.com/category/en/'>en</a>, <a href='http://zonderr.wordpress.com/category/gmic/'>g'mic</a>, <a href='http://zonderr.wordpress.com/category/plugin/'>plugin</a> Tagged: <a href='http://zonderr.wordpress.com/tag/gmic/'>g'mic</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=3&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zonderr.wordpress.com/2010/09/18/gmic-from-the-gimp-plugin-to-the-command-line/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/5a21a09790b0a3dbcf83817a6388fdd5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zonderr</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2010/09/capture.png?w=300" medium="image">
			<media:title type="html">Here! down left!</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2010/09/utilities-terminal.png" medium="image">
			<media:title type="html">Utilities-terminal</media:title>
		</media:content>
	</item>
		<item>
		<title>G’mic Command Line: First steps</title>
		<link>http://zonderr.wordpress.com/2010/09/13/gmic-command-first-steps/</link>
		<comments>http://zonderr.wordpress.com/2010/09/13/gmic-command-first-steps/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 19:42:31 +0000</pubDate>
		<dc:creator>zonderr</dc:creator>
				<category><![CDATA[en]]></category>
		<category><![CDATA[g'mic]]></category>

		<guid isPermaLink="false">http://zonderr.wordpress.com/?p=5</guid>
		<description><![CDATA[0-Unnecessary introduction Before being a popular Gimp plugin, G&#8217;mic is a command line tool devoted to image manipulation. This tutorial assumes that commands are given on a Unix shell command line. Windows user will have to adapt, and might want to install MinGW to be more comfortable with command line use. It is also possible <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=5&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>0-Unnecessary introduction</h3>
<p>Before being a popular <a id="zrw3" title="Gimp plugin" href="http://gmic.sourceforge.net/gimp.shtml">Gimp plugin</a>, <a href="http://gmic.sourceforge.net/">G&#8217;mic</a> is a command line tool devoted to image manipulation. This tutorial assumes that commands are given on a Unix shell command line. Windows user will have to adapt, and might want to install <a id="g_q6" title="MinGW" href="http://www.mingw.org">MinGW</a> to be more comfortable with command line use. It is also possible to test notions explained here below in a <a title="Howto create a custom filter in the G'mic plug-in" href="../2010/11/13/howto-create-a-custom-filter-in-the-gmic-plug-in/">script built for the plug-in</a>.</p>
<div>
<p>Every G&#8217;mic command line formally looks that way:</p>
<pre>gmic -instruction1 arguments -instruction2 arguments etc...</pre>
<p>Everything is explained in the <a id="f0gv" title="official documentation page" href="http://gmic.sourceforge.net/reference.shtml">official reference page</a>. But anyone human would need some more developed explanations. Here are some.</p>
<h3>1-A basic example</h3>
<p>Before applying any treatment on an image, G&#8217;mic has to load it with the<em> -input</em> instruction. After any treatment being applied, you might want to unload the final result on your hard disk with the <em>-output</em> instruction.</p>
<p>Let&#8217;s use a basic example. To rotate 90° an image called image.jpg and get the result as a PNG file called image.png, you&#8217;d use the following command:</p>
<pre>gmic -input image.jpg -rotate 90 -output image.png</pre>
<p>You&#8217;ll notice that G&#8217;mic returns in your terminal the details of all the operations that occurred. For the previous command line, you should have had something like:</p>
<pre>[gmic]-0./ Start G'MIC instance.
[gmic]-0./ Input file 'image.jpg' at position [0] (1 image 512x384x1x3).
[gmic]-1./ Rotate image [0] of 90 deg., black borders and linear interpolation.
[gmic]-1./ Output image [0] as file 'image.png'.
[gmic]-1./ End G'MIC instance.</pre>
<p>So you won&#8217;t be able to say that you didn&#8217;t know what happened.</p>
<p style="text-align:center;">&nbsp;</p>
<h4><a href="http://zonderr.files.wordpress.com/2010/09/rouge2.png"><img class="aligncenter size-medium wp-image-19" title="Please rotate" src="http://zonderr.files.wordpress.com/2010/09/rouge2.png?w=300&#038;h=288" alt="" width="300" height="288" /></a></h4>
<p style="text-align:center;"><a href="http://www.flickr.com/photos/rantz/4537655964">From Rantz</a>, <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">CC-by-nc-sa</a></p>
<h3>2-Aliases</h3>
<p>In order to save typing time, the most common instructions have aliases. For example, <em>-input</em> can be replaced by<em> -i </em>and <em>-output </em>by <em>-o</em>. So, our basic example can be rewritten as:</p>
<pre>gmic -i image.jpg -rotate 90 -o image.png</pre>
<p>In fact, the <em>-input</em> instruction is that common that an even faster way to invoke it has been implemented in G&#8217;mic: just type the image name directly without any instruction before. Indeed, the next command line is the exact equivalent to the previous one:</p>
<pre>gmic image.jpg -rotate 90 -o image.png</pre>
<p>Don&#8217;t expect more, this is as fast as it can get.</p>
<h3>3-Details about <em>-output</em></h3>
<h4>3.1-Formats</h4>
<p>You can get an output anytime in the command line (before or after an operation) and the name of the output file determine the format. For instance, with the following command line, you get 3 images in 3 different formats, the BMP one has not undergone any rotation, the other ones have.</p>
<pre>gmic image.jpg -o image.bmp -rotate 90 -o image.png -o image.tga</pre>
<p>By the way, by default, G&#8217;mic saves JPEG files with quality 100, which is probably more than what you&#8217;d want. To save at quality 95, use <em>-o image.jpg,95<br />
</em></p>
<h4>3.2-Display</h4>
<p>If you don&#8217;t specify any <em>-output</em> (or <em>-o</em>) instruction or if you explicitly give the <em>-display </em>instruction, then G&#8217;mic will display your image on the screen. The 2 next command lines do the same thing: they display the image after a 45° rotation:</p>
<pre>gmic image.jpg -rotate 45
gmic image.jpg -rotate 45 -display</pre>
<p>press &#8216;q&#8217; to quit the display screen.</p>
<p>There is actually a lot to say about the display screen, but it won&#8217;t be said now.</p>
</div>
<h3>4-The arguments of the instruction</h3>
<p>Since the beginning, the image is rotated, just rotated, but like most G&#8217;mic instructions, the <em>-rotate</em> instruction possesses many arguments to rotate in a specific way. If you look at the <a id="d7qb" title="official documentation" href="http://gmic.sourceforge.net/reference.shtml">official reference page</a>, you&#8217;ll find the lines explaining how <em>-rotate </em>works. It begins by:</p>
<div>
<p><strong><span style="color:green;">-rotate </span></strong> angle,_borders,_interpolation,_cx[%],_cy[%],_zoom</p>
<p>This means that <em>-rotate</em> may have until 6 arguments. The first one (angle) has to be specified. The other ones begin by an underscore, it means that they are optional. Just make some tests and you&#8217;ll understand how it works. For example, try these lines:</p>
<pre>gmic image.jpg -rotate 30,1
gmic image.jpg -rotate 30,0,0,50%,50%
gmic image.jpg -rotate 30,0,0,0%,0%,0.5</pre>
<p>You can also get that off-line with <em>man gmic </em>or <em>gmic -h.</em></p>
</div>
<h3>5-dealing with several images</h3>
<h4>5.1-Many just like one</h4>
<div>
<p>You can deal with many images at a time, just load them all. For example, the following command lines load the images and display them:</p>
<pre>gmic image1.jpg image2.jpg image3.jpg
gmic image*.jpg</pre>
<p>If you write your command lines as in the previous chapter, then G&#8217;mic instructions are applied on every loaded images. By using the next command line:</p>
<pre>gmic image*.jpg -rotate 90 -o image.png</pre>
<p>you tell G&#8217;mic to rotate all the <em>image*.jpg</em> files and to save them as a png file. But it won&#8217;t save several images in one file called <em>image.png</em>, it will name them <em>image_000001.png, image_000002.png, image_000003.png</em>, etc.</p>
</div>
<h4 id="some_images">5.2-Restricting an instruction to only some images</h4>
<div>
<p>You can specify on what images applying an instruction by adding the image number, starting by 0 under brackets:</p>
<pre>gmic image*.jpg -rotate[0] 90</pre>
<p>only rotates the first loaded image.</p>
<pre>gmic image*.jpg -o[1] image.png</pre>
<p>saves only the second one as <em>image.png</em>.</p>
<p>If you use negative numbers, you start by the last one:</p>
<pre>gmic image*.jpg -rotate[-1] 90</pre>
<p>only rotates the last loaded image.</p>
<pre>gmic image*.jpg -rotate[-2] 90</pre>
<p>only rotates the second last one.<br />
You can also select a set of images to manipulate:</p>
<div>
<table id="mp6i" class="zeroBorder" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[0,2,-1] 90</code></td>
<td>rotates the first, the third and the last one.</td>
</tr>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[0-9] 90</code></td>
<td>rotates the 10 first images.</td>
</tr>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[0-9:3] 90</code></td>
<td>rotates every 3 images starting from the first one and finishing at the tenth one. It means the first, the fourth, the seventh and the tenth one.</td>
</tr>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[0,-4--1] 90</code></td>
<td>rotates the first and the 4 last ones.</td>
</tr>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[50%-100%] 90</code></td>
<td>rotates the second half of the image list.</td>
</tr>
<tr>
<td width="300" valign="top"><code>gmic image*.jpg -rotate[0,50%--1]  90</code></td>
<td>rotates the first image and the second half of the image list.</td>
</tr>
</tbody>
</table>
</div>
</div>
<h4><a href="http://zonderr.files.wordpress.com/2010/09/foret_petite2.png"><img class="aligncenter size-medium wp-image-19" title="Is that clear?" src="http://zonderr.files.wordpress.com/2010/09/foret_petite2.png?w=300&#038;h=288" alt="" width="300" height="288" /></a></h4>
<p style="text-align:center;"><a href="http://www.flickr.com/photos/rantz/4525158916">Modified from Rantz</a>, <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">CC-by-nc-sa</a></p>
<h4>5.3-Keeping the original with double dash</h4>
<p>By default, an instruction replace the original image by the processed one. There is a way to keep the original: use a double dash (- -). Ex:</p>
<pre>gmic image.jpg --rotate 90</pre>
<p>produces 2 images: the untouched image.jpg and the rotated image.jpg. More details are <a href="http://zonderr.wordpress.com/2011/02/18/about-the-image-stack/">avalaible</a>.</p>
<h4>5.4-Manipulating the image list</h4>
<div>
<p>As you have seen in the previous chapter, the image order is important. You can change that order at any time by using <em>-move </em>or <em>-reverse:<br />
</em></p>
<pre>gmic image*.jpg -move[50%-100%] 0</pre>
<p>moves the second half of the image list at the beginning</p>
<pre>gmic image*.jpg -reverse</pre>
<p>reverses the order of all the images.<br />
You can also keep only some of the images in your list with <em>-keep</em> or get rid of some with <em>-remove</em>. If you feel lost sometime, check what G&#8217;mic returns in your terminal, it should tell you how many images are left.</p>
<h3>6-Custom commands</h3>
<div>
<p>Once you begin to play around with G&#8217;mic, command lines can become pretty long. A solution is to write things in a custom command file. Many custom commands already exist, you can study and learn <a id="m11b" title="gmic_def.gmic" href="http://cimg.cvs.sourceforge.net/viewvc/cimg/CImg/examples/gmic_def.gmic">from them</a>. It would probably help to get some more explanation on the art of writing custom commands but you won&#8217;t find them here. All that will be said is that if you need to load your custom command file before using it.</p>
<p>This is done with the instruction <em>-command</em> or <em>-m</em> or even without any instruction if your file finishes by .gmic. So, the three followings lines do the same thing:</p>
<pre>gmic -command my_custom_command_file.gmic image.jpg -my_command
gmic -m my_custom_command_file.gmic image.jpg -my_command
gmic my_custom_command_file.gmic image.jpg -my_command</pre>
</div>
</div>
<h3>7-Going further</h3>
<p>Logically following this tutorial is <a href="http://zonderr.wordpress.com/2010/10/06/gmic-image-and-format/">that article</a>. Then, to increase your G&#8217;mic culture, you should probably click on <a id="hau4" title="gallery's images" href="http://gmic.sourceforge.net/gallery.shtml">gallery’s images</a> and to master the technique, don&#8217;t forget the <a id="y4ra" title="custom command file" href="http://cimg.cvs.sourceforge.net/viewvc/cimg/CImg/examples/gmic_def.gmic">custom command file</a>.<br />
You are also invited to share your problems and solutions <a href="http://www.flickr.com/groups/gmic">at the forum</a>.</p>
<p><a href="http://www.flickr.com/photos/rantz/4525158916"><img class="aligncenter" title="Twisted Traveling, From Rantz CC-BY-NC-SA" src="http://farm5.static.flickr.com/4023/4525158916_04b169a8a5.jpg" alt="" width="400" height="400" /></a></p>
<p style="text-align:center;"><a href="http://www.flickr.com/photos/rantz/4525158916">From Rantz</a>, <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">CC-by-nc-sa</a></p>
<br />Filed under: <a href='http://zonderr.wordpress.com/category/en/'>en</a>, <a href='http://zonderr.wordpress.com/category/gmic/'>g'mic</a> Tagged: <a href='http://zonderr.wordpress.com/tag/gmic/'>g'mic</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zonderr.wordpress.com&#038;blog=15847821&#038;post=5&#038;subd=zonderr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zonderr.wordpress.com/2010/09/13/gmic-command-first-steps/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/5a21a09790b0a3dbcf83817a6388fdd5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zonderr</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2010/09/rouge2.png" medium="image">
			<media:title type="html">Please rotate</media:title>
		</media:content>

		<media:content url="http://zonderr.files.wordpress.com/2010/09/foret_petite2.png?w=300" medium="image">
			<media:title type="html">Is that clear?</media:title>
		</media:content>

		<media:content url="http://farm5.static.flickr.com/4023/4525158916_04b169a8a5.jpg" medium="image">
			<media:title type="html">Twisted Traveling, From Rantz CC-BY-NC-SA</media:title>
		</media:content>
	</item>
	</channel>
</rss>
