Add a watermark to an image uploaded in CKEditor

Posted on Updated on

Adding watermarks to uploaded images is a much sought after feature in many media and news agency websites. There is an easy way to add a watermark to an image uploaded in any website using CKEditor.

Here is the method to add a watermark to an image uploaded via CKFinder. There is a plugin in CKFinder called watermark which needs to be configured before we can use it. Follow the steps below to configure it.

In the SetupCKEditor Method:

public override void SetConfig()
Plugins = new string[] {
“CKFinder.Plugins.Watermark, CKFinder_Watermark”
// Settings for extra plugins.
PluginSettings = new Hashtable();
PluginSettings.Add(“ImageResize_smallThumb”, “90×90” );
PluginSettings.Add(“ImageResize_mediumThumb”, “120×120” );
PluginSettings.Add(“ImageResize_largeThumb”, “180×180” );

// Name of the watermark image in plugins/watermark folder
PluginSettings.Add(“Watermark_source”, “logo.gif”);
//if the watermark alignment is to the right:
PluginSettings.Add(“Watermark_marginRight”, “10”);
//if the watermark alignment is to the left:
PluginSettings.Add(“Watermark_marginLeft”, “5”);
PluginSettings.Add(“Watermark_marginBottom”, “5” );
PluginSettings.Add(“Watermark_quality”, “90” );
PluginSettings.Add(“Watermark_transparency”, “80” );


Now after you enabled the watermark feature inside the CKEditor: you can add the “CKFinder_Watermark.dll” to your application to start using this feature. I adjusted the dll to allow the user to choose the position of the watermark: (right, left, top, bottom, transparency…)

using System;
using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Web;
using System.Web.UI;
using System.Collections;

namespace CKFinder.Plugins
public class Watermark : CKFinder.CKFinderPlugin
public string JavascriptPlugins
get { return “”; }

public void Init(CKFinder.Connector.CKFinderEvent CKFinderEvent)
CKFinderEvent.AfterFileUpload += new CKFinder.Connector.CKFinderEvent.Hook(CKFinderEvent_AfterFileUpload);

if (!CKFinder.Connector.Config.Current.PluginSettings.ContainsKey(“Watermark_source”))
CKFinder.Connector.Config.Current.PluginSettings[“Watermark_source”] = “logo.gif”;
if (!CKFinder.Connector.Config.Current.PluginSettings.ContainsKey(“Watermark_marginRight”))
CKFinder.Connector.Config.Current.PluginSettings[“Watermark_marginRight”] = “0”;
if (!CKFinder.Connector.Config.Current.PluginSettings.ContainsKey(“Watermark_marginLeft”))
CKFinder.Connector.Config.Current.PluginSettings[“Watermark_marginLeft”] = “0”;
if (!CKFinder.Connector.Config.Current.PluginSettings.ContainsKey(“Watermark_marginBottom”))
CKFinder.Connector.Config.Current.PluginSettings[“Watermark_marginBottom”] = “5”;
if (!CKFinder.Connector.Config.Current.PluginSettings.ContainsKey(“Watermark_quality”))
CKFinder.Connector.Config.Current.PluginSettings[“Watermark_quality”] = “90”;
if (!CKFinder.Connector.Config.Current.PluginSettings.ContainsKey(“Watermark_transparency”))
CKFinder.Connector.Config.Current.PluginSettings[“Watermark_transparency”] = “80”;

private void CKFinderEvent_AfterFileUpload(object sender, CKFinder.Connector.CKFinderEventArgs e)
if (!File.Exists((string)[1]))
catch { }

private void CreateWatermark(string sourceFile)
string logoImageName = (string)CKFinder.Connector.Config.Current.PluginSettings[“Watermark_source”];
string logoImageFile = logoImageName;

//search watermark image
if (!File.Exists(logoImageFile))
if (File.Exists(HttpContext.Current.Server.MapPath(logoImageFile)))
logoImageFile = HttpContext.Current.Server.MapPath(logoImageFile);
logoImageFile = HttpContext.Current.Server.MapPath(((Page)HttpContext.Current.Handler).ResolveUrl(“~/ckfinder/plugins/watermark/” + logoImageName));
if (!File.Exists(logoImageFile))
logoImageFile = HttpContext.Current.Server.MapPath(((Page)HttpContext.Current.Handler).ResolveUrl(“ckfinder/plugins/waterrmark/” + logoImageName));
if (!File.Exists(logoImageFile))

//load configuration
int marginBottom = 0, marginRight = 0, marginLeft = 0, transparency = 0;
int.TryParse((string)CKFinder.Connector.Config.Current.PluginSettings[“Watermark_marginBottom”], out marginBottom);
int.TryParse((string)CKFinder.Connector.Config.Current.PluginSettings[“Watermark_marginRight”], out marginRight);
int.TryParse((string)CKFinder.Connector.Config.Current.PluginSettings[“Watermark_marginLeft”], out marginLeft);
if (int.TryParse((string)CKFinder.Connector.Config.Current.PluginSettings[“Watermark_transparency”], out transparency))
if (transparency > 100) transparency = 100;
if (transparency < 0) transparency = 0;
transparency = transparency * 255 / 100;
else transparency = 255;

//load bitmaps
Image sourceImage = new Bitmap(sourceFile);
Bitmap destinationBmp = new Bitmap(sourceImage.Width, sourceImage.Height);
Bitmap logoImage = new Bitmap(logoImageFile);
Graphics graphics = Graphics.FromImage(destinationBmp);

//convert to indexes image
Bitmap bitmapImage = CreateNonIndexedImage(logoImage);

//set transparency
for (int i = 0; i < logoImage.Width; i++)
for (int j = 0; j < logoImage.Height; j++)
Color logoImagePixel = logoImage.GetPixel(i, j);
if (logoImagePixel.A != 0)
bitmapImage.SetPixel(i, j, Color.FromArgb(transparency, logoImagePixel));

//resize watermark – if is necessary
if (logoImage.Width > sourceImage.Width || logoImage.Height > sourceImage.Height)
bitmapImage = resizeImage(logoImage,
new Size(logoImage.Width > sourceImage.Width ? sourceImage.Width : logoImage.Width,
logoImage.Height > sourceImage.Height ? sourceImage.Height : logoImage.Height));
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
System.Drawing.Imaging.ImageFormat sourceImageFormat = sourceImage.RawFormat;
graphics.DrawImage(sourceImage, new PointF(0, 0));

if (marginLeft > 0)
graphics.DrawImage(bitmapImage, marginLeft, sourceImage.Height – bitmapImage.Height – marginBottom);
graphics.DrawImage(bitmapImage, sourceImage.Width – bitmapImage.Width – marginRight, sourceImage.Height – bitmapImage.Height – marginBottom);

//Dispose objects
destinationBmp.Save(sourceFile, sourceImageFormat);

private Bitmap resizeImage(Image imgToResize, Size size)
int sourceWidth = imgToResize.Width;
int sourceHeight = imgToResize.Height;
float nPercent = 0;
float nPercentW = nPercentW = ((float)size.Width / (float)sourceWidth);
float nPercentH = nPercentH = ((float)size.Height / (float)sourceHeight);
nPercent = nPercentH < nPercentW ? nPercentH : nPercentW;

int destWidth = (int)(sourceWidth * nPercent);
int destHeight = (int)(sourceHeight * nPercent);

Bitmap bitmap = new Bitmap(destWidth, destHeight);
Graphics graphics = Graphics.FromImage((Image)bitmap);
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.DrawImage(imgToResize, 0, 0, destWidth, destHeight);
return bitmap;

private Bitmap CreateNonIndexedImage(Bitmap src)
Bitmap newBmp = new Bitmap(src.Width, src.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
using (Graphics gfx = Graphics.FromImage(newBmp))
gfx.DrawImage(src, 0, 0);
return newBmp;

Now after applying all these options, whenever the user upload any image into the CKEditor, the selected watermark will be displayed in the position he specified.

To download the original file for the CKFinder_Watermark.dll you can use the link below:

Or more details on the CKEditor plugins:

Team Foundation Server 2015

Posted on Updated on

On August 6, 2015 the newest version of the Team Foundation Server (TFS) was released with the collaboration platform at the core of Microsoft’s application lifecycle management (ALM) solution.

You can install Team Foundation Server from the following link.

Download:   Team Foundation Server 2015 RTM

Basic license expanded

The following features are now available to all Team Foundation Server users with a “Basic” license:

  • Web-based test execution
  • Agile portfolio management
  • Work item chart authoring
  • Team Rooms

What this means: All teams of five or fewer members with a “Basic” license have access to these features using Team Web Access for free, while larger teams can access this functionality at a much lower price point.

Changes to schema in databases

Team Foundation Server 2015 includes a large number of changes to the schema used in its databases, and as such, an upgrade from TFS 2013 and older releases is expected to take a significant amount of time. Because upgrades are offline, Microsoft is providing a tool, TfsPreUpgrade.exe, which can be used to perform the most time-expensive portions of the upgrade online against TFS 2013 QU4 and QU5 deployments. The Upgrade wizard includes a readiness check, which warns you if your database is large enough that running TfsPreUpgrade.exe is recommended.

SharePoint Extensions

In the past, if you wanted your Team Foundation Server integrated with a SharePoint instance that was on a different machine, you could either run the Team Foundation Server installer on the SharePoint server and then configure TFS Extensions for SharePoint or run a special installer (tfs_sharePointExtensions.exe) that put only the bits necessary for configuring TFS Extensions for SharePoint.

We have removed this special installer, so to integrate your Team Foundation Server with SharePoint, you must run the Team Foundation Server installer on the SharePoint server and then configure TFS Extensions for SharePoint.

More details about TFS 2015

Akkar District – Lebanon

Posted on Updated on

Akkar (Arabic: عكار‎) is a district (Qadaa) in the North Governorate, Lebanon. It covers an area of 788 km2 (304 sq mi) and has a population of 198,174. The capital lies at Halba. The name Akkar is derived from the Syriac word, Akkare, meaning farmers.

The district is characterized by the presence of a 20150426_125941 (1024x576)relatively large coastal plain, with high mountains to the east. Akkar had been governed during the last 400 years by the Emirs and the beiks of the Merheb (Muriby) family. After the civil war this was no longer the case as peasants took over the land with the aid of Syrian troops during the civil war. The largest cities in Akkar are Halba, al-Bireh (previously called “Biret el Hokem” where we find the Castle of Merheb Family), Kobayat (Quobayet).

Akkar has many important Roman and Arabic archaeological sites. One of the most famous archaeological sites and the birthplace of the Emperor Alexander Severus, is the Tell of Arqa near the town of Miniara. Several prehistoric sites were found in the Akkar plain foothills that were suggested to have been used by the Heavy Neolithic Qaraoun culture at the dawn of the Neolithic revolution.

If you haven’t been there, have a look on all the green places all over Akkar. It should be considered one of the most important reserves in Lebanon.

10 reasons to visit Armenia

Posted on

Discover the most ancient, mysterious and at the same time a modern country!

10  reasons to visit Armenia:12

1. MOUNT ARARAT and lake Sevan

To see the most beautiful mountain in the world – biblical Mount Ararat, the highest mountain in the world from its base (not sea level), where the Noah’s ark landed after the Great Flood and the second highest lake in the world after Titikaka!


Armenia is the first country in the world which officially adopted Christianity in 301, 24 years earlier than Rome. The first Christian church of the world (301-303) is located in Armenia.It means here you’ll see the world’s oldest churches and monasteries located in stunning natural settings.

3. WORLD’S OLDEST SHOE and oldest stonehenge in the world

To see the world’s oldest shoe (5500years old), as well as world’s oldest winery found in Areni Cave and 8000 year old Stonehenge located in the South part of Armenia.223 large stone tombs are standing here waiting for explorers.


To taste the Armenian pomegranate  wine and the most sophisticated Armenian cognac which is the visit card of Armenia.


To eat healthy, organic and delicious food as the Armenian cuisine is one of the oldest and tastiest in the world and to taste the sun-kissed apricots of Ararat Valley. “Prunus armeniaca” in Latin means “Armenian plum” as Armenia is the homeland of the apricot, the only fruit containing gold in its composition.


To ride the world’s longest aerial tramway (5.7km), “Tatev wings” which will take you to the huge monastic complex of Tatev (10th century), indeed a fairy-tale fortress – monastery nestled on a promontory surrounded by deep gorges.



To stand on the old Silk Road, its bridges and see caravanserais (hotels of antiquity). The Silk Road was about 7000km long, and 500km passed through Armenia.


You will be amazed by the diversity of landscapes of this small, yet ancient country with over 5000 year history. From semi deserts up to the alpine meadows, snow-capped peaks  and white sand beaches of the Lake Sevan, the lush forests of Dilijan or the huge red rocks of Noravank Canyon where we can organize incentive for you from A to Z.

10.  YEREVAN day and night life

To visit one of the world’s ancient continuously inhabited cities – Yerevan, the pink-colored capital of Armenia founded in 782 B.C. It’s called so because most of its building were built  by the local pink rock (tuff) quarried in Armenia. Erebuni (Yerevan) fortress is 29years older than Rome.This historical city becomes quite another place of ineterst during the night.Bars,Discotecs and casonies are waiting for you to enjoy and have unforgettable time. 21

Serendipity Happens…

Posted on Updated on

Here are some quotes from my favorite movie – like to remember from time to time..

Jonathan Trager, prominent television producer for ESPN, died last night from complications of losing his soul mate and his fiancee. He was 35 years old. Soft-spoken and obsessive, Trager never looked the part of a hopeless romantic. But, in the final days of his life, he revealed an unknown side of his psyche. This hidden quasi-Jungian persona surfaced during the Agatha Christie-like pursuit of his long reputed soul mate, a woman whom he only spent a few precious hours with. Sadly, the protracted search ended late Saturday night in complete and utter failure. Yet even in certain defeat, the courageous Trager secretly clung to the belief that life is not merely a series of meaningless accidents or coincidences. Uh-uh. But rather, its a tapestry of events that culminate in an exquisite, sublime plan. Asked about the loss of his dear friend, Dean Kansky, the Pulitzer Prize-winning author and executive editor of the New York Times, described Jonathan as a changed man in the last days of his life. “Things were clearer for him,” Kansky noted. Ultimately Jonathan concluded that if we are to live life in harmony with the universe, we must all possess a powerful faith in what the ancients used to call “fatum”, what we currently refer to as destiny.

Jonathan: Maybe the absence of signs is a sign.


Jonathan: This is the ultimate blend to drink. How’d you find this place?

Sara: I first came in because of the name: Serendipity. It’s one of my favorite words.

Jonathan: It is? Why?

Sara: It’s such a nice sounding word for what it means: a fortunate accident.


Sara: You don’t have to understand. You just have to have faith.

Jonathan: Faith in what?

Sara: Destiny


read more

What will happen to my Facebook account if I die?

Posted on

I always wondered what will ever happen to my Facebook account if I die accidentally or just die after a period of time. Statistics said in 2065, Facebook will have more dead people than live ones! This is strange, I keep on updating my profile with pictures every now and then and suddenly I disappear. This question popped a lot to my mind, and I was amazed with the results Facebook made.

Facebook has something called Memorialization Request!  Here what I find:

From Facebook’s FAQ:

It is our policy to memorialize all deceased users’ accounts on the site. When an account is memorialized, only confirmed friends can see the profile (timeline) or locate it in Search. The profile (timeline) will also no longer appear in the Suggestions section of the Home page. Friends and family can leave posts in remembrance.

In order to protect the privacy of the deceased user, we cannot provide login information for the account to anyone. However, once an account has been memorialized, it is completely secure and cannot be accessed or altered by anyone.

If you need to report a profile (timeline) to be memorialized, please click here.

While Facebook takes steps to verify requests, the requestor doesn’t have to be the decedent’s executor or even a family member, as anyone can complete the request form. This removes some control from the executor, but generally ensures that memorialization takes place at the right time.

Delete the profile

Upon request from a close family member Facebook will remove a deceased user’s profile entirely.

Quoting the FAQ again:

“We will process certain special requests for verified immediate family members, including requests to remove a loved one’s account. This will completely remove the profile (timeline) and all associated content from Facebook, so no one can view it.

For all special requests, we require verification that you are an immediate family member or executor. Requests will not be processed if we are unable to verify your relationship to the deceased.

Examples of documentation that we will accept include:

  • The deceased’s birth certificate
  • The deceased’s death certificate
  • Proof of authority under local law that you are the lawful representative of the deceased or his/her estate.

If you are an immediate family member and would like to request that we remove your loved one’s account from the site, click here. You may also use this form if you have a special request regarding the deceased user’s account.”

Download the account’s information

Recently WGRZ reported that Facebook will also allow family members to download the account contents of the deceased, if prior authorization or a court order is present.

Quoting a statement from Facebook to WGRZ:

“We will provide the estate of the deceased with a download of the account’s data if prior consent is obtained from or decreed by the deceased, or mandated by law.”  – Fred Wolens,Facebook Policy Communications

This is the first time that we’ve heard this last part of Facebook’s policy at The Digital Beyond. Essentially this means that you can leave instructions in your will for your family to have access to the information on your Facebook account, and Facebook will honor that request. Furthermore, the last statement, “mandated by law,” indicates that Facebook will comply with estate laws from several states, which essentially grant the executor access to information stored at social networking websites specifically or all electronic information, depending upon the state.

More to read about this strange issue (What happens to your Facebook account when you die?)



What’s new in SharePoint 2013?

Posted on

Since SharePoint 2013 was released, it’s been heralded as the greatest release yet from Microsoft’s collaboration platform. But what’s so great about it? Is it really any better than SharePoint 2010 for doing what you want it to? Are there any new features in Sharepoint 2013 that make it worth upgrading?

Here are some Top Features of SharePoint 2013 that will start to sell your business on investigating the Preview. All of these features are documented in TechNet. I will summarize 10 of them, and others to go.
  • Support the tools designers use: Flexibility in Branding – How great will it be that your designers can use Dreamweaver or other popular design products. “Whether that is Adobe Dreamweaver, Microsoft Expression Web, or some other HTML editor. To brand a SharePoint site, designers just create a site design as they typically would, by implementing HTML, CSS, and JavaScript”
  • Offline and Sync of My Site (and other libraries) – “In SharePoint Server 2013 Preview, My Sites include several improvements to saving, synchronization, sharing, and moving of content. Users have the option to synchronize their My Site document library content with a local drive to enable offline access to documents.” Saving and Syncing Content (I really love the new Follow people, documents, sites, and tags to customize their feed!!)
  • Search Engine Optimization & Analytic is in Search – Search is TONS better. Much of this is due to Analytics moving into search. This will make Analytic Processing Component in SharePoint Server 2013 Preview runs different analytics jobs to analyze content in the search index and user actions that were performed on a site to identify items that users perceive as more relevant than others.
  • Content Search WebPart – This webpart is cool, but it may take a demo to understand the power. In many ways this is the next generation of Content Query Web Part. “Content Search Web Part that displays content that was crawled and added to the search index. You can use category pages when you want to aggregate content that meets certain criteria or parameters. For example, in an intranet scenario, all company events are maintained in a list that is shared as a catalog. A query is issued from the Content Search Web Part to return all items from the search index that are specified in the query.” 
  • Optimized mobile browser experience – For some companies this may be the reason to upgrade alone. Mobile is definitely something I have been looking for. “For smartphone mobile devices SharePoint Server 2013 Preview provides a lightweight, contemporary view browsing experience for users to navigate and access document libraries, lists, wikis, and Web Parts. Contemporary view.  This view offers an optimized mobile browser experience to users and renders in HTML5. This view is available to Mobile Internet Explorer version 9.0 or later versions for Windows Phone 7.5, Safari version 4.0 or later versions for iPhone 4.0, and the Android browser for Android 4.0. Classic view   This view renders in HTML format, or similar markup languages (CHTML, WML, and so on), and provides backward compatibility for mobile browsers that cannot render in the new contemporary view” Mobile browser experience Device specific Master Pages – You can target your branding to the device! Targeting different devices such as smartphones, tablets. “Allow a single publishing site to be rendered in multiple ways by using different designs that target different devices.” TechNet Device Specific Branding Feature
  • Rich Workflows – If workflows were a sore point, they’ve gotten a lot better and seem much more able to handle more complex activities including looping and working with webservices (anyone thinking orchestration?). “A new action that enables no-code web service calls from within a workflow, New actions for creating a task and starting a task process and New workflow building blocks such as Stage, Loop, and App Step” With Azure Workflows you can even do “REST and Service Bus Messaging” Workflow in SharePoint 2013 Machine Translation – Looking forward to really seeing what our business can do with this translation service. Automated translation into various languages!
  • Development gets more familiar – Developers who are not SharePoint developers will find SharePoint 2013 preview a lot easier to work with. Leverage your existing “ASP.NET, Apache, C#, Java, and PHP. The new cloud app model gives you the freedom of choice.”
  • New App Model – This new app model will take you into the New Online World – “The new app model embraces web standards: You can develop the user experience with HTML and JavaScript, and leverage SharePoint and other REST services right from the client using JavaScript and JSON. You can even create your own REST services and provide a web hosting platform of your choice to handle complex logic and integration of data and services. The new cloud app model also takes advantage of OAuth to allow for secure communication between SharePoint and remote hosted apps and services.”
  • Shredded Storage – This is one of my favorite new features. I can’t wait to see what it does to our farm. Shredded storage will remove file duplicates and reduce the amount of content sent across the wire. You can find more on this in the IT pro decks.
  • Social Features: Activity feeds – I really like the idea that I can get real notifications of what’s happening on a site including following documents, following sites, and following people… and automatically following team members (if you want). Communities – I think Microsoft’s new site template communities will be interesting with integrated microblogging. I’m definitely anxious to see how our internal communities use them. 

More info: