Mondeo Posted May 3, 2007 Posted May 3, 2007 I'm building a site for a photographer who wants to sell his work online. To prevent people simply right clicking on the image and choosing save as we're going to "watermark" each image with the website address. Is there any easy way to do this automatically using the image classes? Thanks Quote
Leaders snarfblam Posted May 3, 2007 Leaders Posted May 3, 2007 There is no incredibly quick and easy way to do this, but with some effort you should be able to write a program to automate this process and perform batch-processing. You would have to use the Image class in conjunction with the Graphics class. The process would not really be reversible (you would naturally want to keep the originals) and there might be loss of image quality. Assuming all the files are in the same folder, you would start by asking the user which folder the files are found in. I'm guessing that the images would be JPEGs. You can use the Directory.GetFiles method and specify a file pattern (i.e. "*.jpeg;*.jpg" but I'm not positive about the format) to get a string array containing filenames. Loop through the files, opening them with the Bitmap constructor. Use the Graphics.FromImage function to create a Graphics object which can manipulate the image. You can simply write some text to the image (Graphics.DrawString), use a pre-prepared semi-transparent image (Graphics.DrawImage), or use a pre-prepared but not semi-transparent image and use a color matrix to render the image semi-transparent. After watermarking the image, save it. To optimize image quality and file size, you will probably want to enumerate image saving codecs to find the JPEG codec, with which you can specify the image quality (I can help you with this). Dispose of the image and Graphics objects. Repeat. Hope that helps, and I'll be glad to help out if you hit some bumps along the way. Quote [sIGPIC]e[/sIGPIC]
Administrators PlausiblyDamp Posted May 4, 2007 Administrators Posted May 4, 2007 http://articles.techrepublic.com.com/5100-3513-6131225.html looks like it might be useful. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.