Click here to Skip to main content
13,557,390 members
Click here to Skip to main content
Add your own
alternative version


84 bookmarked
Posted 13 Sep 2006
Licenced CPOL

Batch Image

, 4 Apr 2007
Rate this:
Please Sign up or sign in to vote.
An application to make several images processing elaboration in batch for creating thumbnails in a few minutes
Sample screenshot


This application is useful to generate thumbnails from images in a few minutes with some interesting effects and features.

You can also insert text over images in semitransparence, defining its position, size, shadow, and optionally with a background shape like a rectangle or an ellipse and a 3D effect. Moreover you can impress a watermark image on the target image defining the transparency key, the size in percent respect of the target image, the transparency level, and the position. You can convert images between formats. Finally, you can make an interesting shadow effect like a picture over a sheet. All the elaborations could be done in batch.

Several formats are supported: JPG (with customizable compression level), GIF, PNG, WMF, TIFF, EXIT and ICO.

The tool has a nice look and a user friendly interface.


There are a lot of applications or code samples that make a resize of an image with GDI+.
The basic idea for resizing pictures is well explained in the article Resizing a Photographic image with GDI+ for .NET.

The basic idea for the watermark is well explained in the article Creating a Watermarked Photograph with GDI+ for.NET.

The implementation for resizing and impressing watermark is not much different from the quoted articles, but with some small differences.


The user can navigate files and folders for choosing desired images using the look appeal treeview on the right side of the application window. With a simple double click on a file, an image can be added to panel, otherwise with a left click a context menu appears and makes possible to the user to add or remove a single image or an entire directory containing several images. The presence of the same image on the work panel is checked. When a file or a directory is selected on the treeview, its properties like size, name, etc. are shown on the property grid. If the selected file is an image, a preview is visible just below the navigation tree.

Using the Code

The project is composed of several classes. The most important ones are:

  • UImageContainer - Contains the treeview, the workpanel and the preview for files and images
  • UDirTree - Provides the folder and files navigation
  • Panello - Is the workpanel that contains several UImage controls
  • Uimage - The user control that displays an image on the work panel
  • CImage - Provides the main image processing like resize, watermark, shadow effect, JPG saving, etc.

The follow code lines create the shadow effect:

public void makeshadow(ref Bitmap img, Color backcolor) 
 int imgWidth = img.Width;
 int imgHeight = img.Height;
 // Create a new bitmap with the same size of the original image 
Bitmap workingimg = new Bitmap(imgWidth, imgHeight, PixelFormat.Format24bppRgb); 
workingimg.SetResolution(img.HorizontalResolution, img.VerticalResolution); 
// Create a new graphic object from the new bitmap  
Graphics imgGraphic = Graphics.FromImage(workingimg); 
// Set the interpolation mode imgGraphic.InterpolationMode = intmode; 
// Calculate the new size for drawing the originalimage 
// that is reduced to maintain the total target image size 
int width = (int)((float)img.Width * 94 / 100); 
int height = (int)((float)img.Height * 94 / 100); 
// Create a new brush semitransparent 
SolidBrush BrushShadow = new SolidBrush(Color.FromArgb(10, 0, 0, 0)); 
// Set the background color based on the user preference 
// Create the shadow shifting semi-transparent rectangle over the empty bitmap 
float steps = ((float)imgWidth - width) / 20;
float sottr = 0f; for (float i = 0; i < 10; i++) 
     imgGraphic.FillRectangle(BrushShadow, new Rectangle((int)(sottr), 
		(int)sottr, (int)((float)width+sottr), (int)((float)height+sottr))); 
     sottr += steps; 
// Finally draw the original image but shrink 
imgGraphic.DrawImage(img, new Rectangle(0, 0, width, height), 0, 0, 
	imgWidth, imgHeight, GraphicsUnit.Pixel); 

img = workingimg; 

Points of Interest

Multithreading Capabilities

To enhance the speed of the images elaboration, I made the user free to choose the number of threads that will compute the work from 1 to 10 from a numericalupdown control in the settings panel. The set of images are subdivided into intervals based on the number of maximum usable threads.

The work can be suspended, resumed and aborted by the user.

for (int i = 0 ; i < 11; i++) 
    threads[i] = new Thread(StarkWork);
    threads[i].Priority = ThreadPriority.Lowest;
    threads[i].IsBackground = false; 
intSimultaneous = CONCURRENT_THREADS; 
int interval = (int)Math.Floor((double)((double)total / (double)Simultaneous)); 
int accumulator = 0; 
for (int i = 0; i < Simultaneous-1; i++) 
    ThreadInterval Bounds = new ThreadInterval();
    Bounds.LowerBound = accumulator;
    Bounds.UpperBound = accumulator+interval;
    accumulator += interval; 
ThreadInterval BoundsRemained = new ThreadInterval(); 
BoundsRemained.LowerBound = accumulator;
BoundsRemained.UpperBound = total;


Some Cool Features

The user can choose the transparency key color simply by clicking on the watermark image.


With this tool, you can make thumbnails like this:

Future Developments and Updates

I plan to modify this tool for creating HTML pages.
I have made the modification in another article: An Application to Create Interesting and Fully Customizable Web Photo Gallery.

I chose to keep this article unchanged and attached the code because the target is different: this article is about thumbnails generator in batch, the new article ("Extended Web Gallery") is about HTML pages generation (with plugins).

External Link

For more information like user documentation, visit this page.


English is not my first language, so please excuse any mistakes. This is my first article for The Code Project, so any suggestions and/or feedback will be appreciated.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Italy Italy
I'm an electronic engeneer form Genoa.
I like very much dotnet and C#. I've developed some works like an html gallery generator, a graphic formula viewer (user defined), a webcam grabber and html gallery generator, a little framework for image processing, an image resizer, elaboration in batch and some other application tool.
Actually I'm working in VC++ 6 MFC, but I hope that my future is .net !!!
Some of my works are downloadable at:
Lorenzo Banderali

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
manoj kumar choubey26-Feb-12 20:55
membermanoj kumar choubey26-Feb-12 20:55 
GeneralAll images set to some display Pin
nighttrain121-Feb-11 0:42
membernighttrain121-Feb-11 0:42 
GeneralMy vote of 1 Pin
Wertugo5558-Dec-08 22:15
memberWertugo5558-Dec-08 22:15 
QuestionImage Similarity Pin
3amoor20-Sep-06 7:48
member3amoor20-Sep-06 7:48 
AnswerRe: Image Similarity Pin
Lorenzo1981Ge20-Sep-06 21:17
memberLorenzo1981Ge20-Sep-06 21:17 
GeneralRe: Image Similarity Pin
3amoor21-Sep-06 2:57
member3amoor21-Sep-06 2:57 
GeneralRe: Image Similarity Pin
Lorenzo1981Ge21-Sep-06 7:47
memberLorenzo1981Ge21-Sep-06 7:47 
QuestionRe: Image Similarity Pin
3amoor21-Sep-06 8:01
member3amoor21-Sep-06 8:01 
QuestionImage Reconstruction Pin
3amoor19-Sep-06 4:26
member3amoor19-Sep-06 4:26 
AnswerRe: Image Reconstruction Pin
Lorenzo1981Ge19-Sep-06 7:38
memberLorenzo1981Ge19-Sep-06 7:38 
GeneralRe: Image Reconstruction Pin
3amoor19-Sep-06 9:28
member3amoor19-Sep-06 9:28 
GeneralRe: Image Reconstruction Pin
Lorenzo1981Ge19-Sep-06 21:06
memberLorenzo1981Ge19-Sep-06 21:06 
GeneralImage Crop and Splitting Pin
3amoor18-Sep-06 13:24
member3amoor18-Sep-06 13:24 
GeneralRe: Image Crop and Splitting Pin
Lorenzo1981Ge18-Sep-06 21:47
memberLorenzo1981Ge18-Sep-06 21:47 
GeneralBad url link Pin
T4Top13-Sep-06 20:37
memberT4Top13-Sep-06 20:37 
GeneralRe: Bad url link Pin
Lorenzo1981Ge13-Sep-06 21:43
memberLorenzo1981Ge13-Sep-06 21:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01-2016 | 2.8.180515.1 | Last Updated 4 Apr 2007
Article Copyright 2006 by Lorenzo1981Ge
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid