<?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/"
	>

<channel>
	<title>write text on image programatically &#8211; Sibeesh Passion</title>
	<atom:link href="https://www.sibeeshpassion.com/tag/write-text-on-image-programatically/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Wed, 19 Aug 2020 10:34:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>write text on image programatically &#8211; Sibeesh Passion</title>
	<link>https://www.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Show Recent Blog Posts in GitHub ReadMe using Azure Function</title>
		<link>https://www.sibeeshpassion.com/show-recent-blog-posts-in-github-readme-using-azure-function/</link>
					<comments>https://www.sibeeshpassion.com/show-recent-blog-posts-in-github-readme-using-azure-function/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Mon, 20 Jul 2020 18:30:34 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Azure Function]]></category>
		<category><![CDATA[azure function to get latest blog feed]]></category>
		<category><![CDATA[custom github home page]]></category>
		<category><![CDATA[dynamic image with dynamic text writing c#]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[Github readme]]></category>
		<category><![CDATA[SixLabors.ImageSharp]]></category>
		<category><![CDATA[write text on image programatically]]></category>
		<guid isPermaLink="false">http://sibeeshpassion.com/?p=14165</guid>

					<description><![CDATA[I am showing the image of the titles of my recent 5 blog posts on my GitHub home page automatically. I did it using the Azure Function, Azure is Love, right?]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction</h2>



<p>GitHub recently introduced an option to customize our profile by giving a separate magical repository. This repository name should be the same as your username, for example, https://github.com/SibeeshVenu/sibeeshvenu. This is how you can find this secret repository. </p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="650" height="177" src="/wp-content/uploads/2020/07/Secret-repository.png" alt="" class="wp-image-14167" srcset="/wp-content/uploads/2020/07/Secret-repository.png 650w, /wp-content/uploads/2020/07/Secret-repository-300x82.png 300w, /wp-content/uploads/2020/07/Secret-repository-425x116.png 425w" sizes="(max-width: 650px) 100vw, 650px" /><figcaption>GitHub secret repository</figcaption></figure>



<p>Now opens an endless opportunity that you can do to your GitHub home page, for example, I am showing the image of the titles of my recent 5 blog posts on my home page automatically. I did it using the Azure Function which will return the image and all I had to do in this repository, was to use it. Overall it was fun. </p>



<figure class="wp-block-image size-large"><img decoding="async" width="650" height="302" src="/wp-content/uploads/2020/07/Custom-github-home-page.png" alt="" class="wp-image-14168" srcset="/wp-content/uploads/2020/07/Custom-github-home-page.png 650w, /wp-content/uploads/2020/07/Custom-github-home-page-300x139.png 300w, /wp-content/uploads/2020/07/Custom-github-home-page-425x197.png 425w" sizes="(max-width: 650px) 100vw, 650px" /><figcaption>Custom GitHub home page</figcaption></figure>



<p>Here in this post, we will see how we can develop an Azure Function solution that returns the above-mentioned image.</p>



<h2 class="wp-block-heading">Develop an Azure function</h2>



<p>The first thing that you need to do, is to create a new Azure Function. Go to your Azure portal, and search for Azure Function, the creation process is the same and easy as we create any other Azure resources. If you are interested, you can check out my articles related to <a href="https://sibeeshpassion.com/tag/azure-function/" target="_blank" rel="noreferrer noopener">Azure Function here</a>.</p>



<p>Once you create the Azure function, you are good to go and develop an Azure function application in Visual Studio. Here I am using Visual Studio 2019. </p>



<figure class="wp-block-image size-large"><img decoding="async" width="650" height="702" src="/wp-content/uploads/2020/07/Create-Azure-function-using-visual-studio.jpg" alt="" class="wp-image-14169" srcset="/wp-content/uploads/2020/07/Create-Azure-function-using-visual-studio.jpg 650w, /wp-content/uploads/2020/07/Create-Azure-function-using-visual-studio-278x300.jpg 278w, /wp-content/uploads/2020/07/Create-Azure-function-using-visual-studio-425x459.jpg 425w" sizes="(max-width: 650px) 100vw, 650px" /><figcaption>Create Azure function using visual studio</figcaption></figure>



<p>We are going to create an HttpTrigger Azure function, so make sure you select that option on the next screen. If you need a basic introduction about the HttpTrigger Azure function, you can read this post <a href="https://sibeeshpassion.com/azure-function-as-output-job-topology-of-an-azure-stream-analytics-job/#play-with-azure-function" target="_blank" rel="noreferrer noopener">here</a>. I named my function as GetLatestPosts, and feel free to give any name you wish. This Azure function has the preceding jobs to do.</p>



<ol class="wp-block-list"><li>Get the latest posts details from the feed of my blog</li><li>Create an image with the feed data</li><li>Send back the image as a stream</li></ol>



<h3 class="wp-block-heading">Get the latest posts details from the feed</h3>



<p>You can usually get the feed data by going to {yoursitelink}/feed. For example, I can get my feed data by going to <a href="https://sibeeshpassion.com/feed/">https://sibeeshpassion.com/feed/</a>. So in our function, we will get this data using an XmlReader and Deserialize the same using SyndicationFeed. Please be noted that the Syndication namespace is part of the System.ServiceModel and you should install the Nuget package System.ServiceModel.Syndication. Preceding is the function to retrieve the latest 5 blog posts details.</p>



<script src="https://gist.github.com/SibeeshVenu/d994dd2c5b013333943dae3b52f1e961.js"></script>



<h3 class="wp-block-heading">Create an image with titles </h3>



<p>Now we need a function to generate an image and write the blog posts title to that image dynamically. To do this, we are using the Nuget package called  SixLabors.ImageSharp. Feel free to use any packages you like, the only thing that matters is that we need an image with the blog posts titles. The SixLabors.ImageSharp is indeed an amazing library, I can recommend you to give it a try. This is how your Nuget package installed window should look like now.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="536" src="/wp-content/uploads/2020/07/Required-Nuget-packages-1024x536.jpg" alt="" class="wp-image-14170" srcset="/wp-content/uploads/2020/07/Required-Nuget-packages-1024x536.jpg 1024w, /wp-content/uploads/2020/07/Required-Nuget-packages-300x157.jpg 300w, /wp-content/uploads/2020/07/Required-Nuget-packages-768x402.jpg 768w, /wp-content/uploads/2020/07/Required-Nuget-packages-425x222.jpg 425w, /wp-content/uploads/2020/07/Required-Nuget-packages.jpg 1495w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Required Nuget packages</figcaption></figure>



<p>Now we cna write the function as preceding.</p>



<script src="https://gist.github.com/SibeeshVenu/33b6e46ead886df91d533d9fe9c10ca2.js"></script>



<p>As you can see that there is a Configuration class, from where we take all the configurations. Let&#8217; write that now. You can also use Environment variables here, I may update my repository in the coming days.</p>



<script src="https://gist.github.com/SibeeshVenu/a5cbc95db906783e8b8319cb5f2d0f80.js"></script>



<p>The SixLabors.ImageSharp has an inbuilt extension function called ToBase64String, which will return the image as base64 string. Did you notice that we are using another extension method here, &#8220;ApplyScalingWaterMark&#8221;? Let&#8217;s create a class for our Extension methods so that it will be handy in the future. </p>



<script src="https://gist.github.com/SibeeshVenu/44f2c33e3294be08ba28b8c975712ad5.js"></script>



<h3 class="wp-block-heading">Azure function to return a stream</h3>



<p>As all the supporting methods are ready, let us write our main function, the ultimate job of this function is to convert the base64 string to a stream and return the stream. As simple as that. </p>



<script src="https://gist.github.com/SibeeshVenu/895d90a8d624d2ff663e8147e44a6b99.js"></script>



<p>Once your Azure function is ready, please remember to publish the same to Azure. To publish your Azure Function app, just right click on your project and click Publish and then set up your publish target by choosing the existing Azure Function App, remember we have created one earlier?&nbsp;</p>



<h2 class="wp-block-heading">Develop secret GitHub readme repository</h2>



<p>Here I am assuming that you already created your secret repository. And if yes, you can update the &#8220;readme&#8221; content as follows. Please remember this is just a sample, you can update as you wish.</p>



<script src="https://gist.github.com/SibeeshVenu/cab2f65acc9feb46ce991788118b4c31.js"></script>



<p>Boom!. We did it. Now go to your GitHub home page, and I am sure that you will love your new beautiful, detailed home page.</p>



<h2 class="wp-block-heading">Update</h2>



<p>As GitHub has a very low timeout, sometimes the image created was not showing in my profile. Thus, I had to change the mechanism. I changed my Azure function to a time trigger function that runs every hour and the main functionality of this function now is to generate the image and upload to the Azure blob storage. Now I can directly get the blob image URL in the Readme file. No more timeout issues. Preceding is the codes of the new Azure function. You can also see this in the Dev branch of the repository.</p>



<script src="https://gist.github.com/SibeeshVenu/026e07fe611f82c568658c1cfbbb1e08.js"></script>



<h2 class="wp-block-heading">Source Code</h2>



<p>Please feel free to check out the repositories here.</p>



<ul class="wp-block-list"><li><a href="https://github.com/SibeeshVenu/GitHubFuncs">https://github.com/SibeeshVenu/GitHubFuncs</a></li><li><a href="https://github.com/SibeeshVenu/sibeeshvenu">https://github.com/SibeeshVenu/sibeeshvenu</a></li></ul>



<h2 class="wp-block-heading">About the Author</h2>



<p>I am yet another developer who is passionate about writing and video creation. I have written close to 500 blogs on my&nbsp;<a href="https://sibeeshpassion.com/" target="_blank" rel="noreferrer noopener">blog</a>. And I upload videos on my YouTube channels&nbsp;<a href="https://www.youtube.com/njanorumalayali" target="_blank" rel="noreferrer noopener">Njan Oru Malayali</a>&nbsp;and&nbsp;<a href="https://www.youtube.com/SibeeshPassion" target="_blank" rel="noreferrer noopener">Sibeesh Passion</a>. Please feel free to follow me.</p>



<ul class="wp-block-list"><li><a href="https://github.com/SibeeshVenu">GitHub</a></li><li><a href="https://medium.com/@sibeeshvenu">medium</a></li><li><a href="https://twitter.com/sibeeshvenu">Twitter</a></li></ul>



<h2 class="wp-block-heading">Your turn. What do you think?</h2>



<p>Thanks a lot for reading. Did I miss anything that you may think which is needed in this article? Could you find this post useful? Kindly do not forget to share your feedback.</p>



<p>Kindest Regards<br>Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/show-recent-blog-posts-in-github-readme-using-azure-function/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
