LancsozeResize.exe – A prototype for an Image Processing Library Package
In the development of the CinepanPlayer, I needed a resize function to resize the images, and I used the multi-CPU 192-bit Lanzcos Resize function I wrote for Sagelight.
Since this resize (in the Cinepan Player) is done on fairly large images at run-time, I needed something fast, so I borrowed the code I wrote in SSE assembly language from Sagelight.
Since I made it a generic class for the Cinepan Player, I wrote a sample LanczosResize.exe which anyone can use.
It’s a command-line program that will take your JPEG image, resize it to the dimensions you specify in the Lanczos Algorithm you choose. It will then write out a new JPEG with the new dimensions in the JPEG Quality desired (or the default quality of 80).
More about how to use it a couple sections down
A prototype/beta for an Image Processing Library Package
For a while, I have been thinking about releasing an Image Processing Library Package that you can use on the command line, or, perhaps, calling it from your program as a .DLL.
Sagelight has a number of fast, multi-processing, intensive algorithms that are very useful, and the Lanczos resize is just one of them. I thought I’d put out LanczosResize.exe as a prototype and see what people think.
There are many other functions such a package could perform, such as Gaussian Blur, Unsharp Mask, Definiton, Focus, 13 different types of Saturation, Vibrance, Curves (i.e. specify the curve points and color space), Color Space conversion, other resizing methods, fill light, noise reduction, edge detection, various analyses, HDR, Lens Blur, Box Blur, Median, Surface Blur, Contrast (various methods), Brightness, Gamma, image merging (i.e. Linear, Soft Light, Color, etc.), and so-forth.
Most of these items are very useful for professional projects and image analysis, as well as hobbyists looking to perform functions on their images for various reasons – for example, a quick Gaussian Blur or Noise Reduction prior to an HDR pass, and that sort of thing.
With a robust library, putting functions together can do amazing things to the image, too.
It’s just a thought, and I thought I’d release the Lanczos resize to see what people think and to get feedback.
Using Lanczos Resize
Since it’s a prototype of a possible larger program, the options are pretty simple:
LanczosResize <inputfile> <outputfile> –L<LanczosType> –Size <WidthxHeight>/<%NewSize> [-quality <JpegQuality>]
- InputFile = your input file, such as MyJpeg.jpg (must be a JPEG image)
- OutputFile = your outputfile, such as MyNewJpeg.jpg.
- LanczosType = 2,3,5, or 8.
- Size. This can be <width>x<height> (such as 1024×768) or a percent value, such as 50% (or 43.145% for better accuracy). Using a percent value maintains the aspect ratio of the image, where using widthxheight creates an image of exactly those dimensions.
- Quality. This is optional and specifies the output jpeg quality, and is a number from 1-100. 100 is the best quality (and highest file size). Default quality is 80, which is a good high-quality output.
- LanczosResize MyFile.jpg MyFile2.jpg –l5 –size 40.3%. Resizes MyFile.jpg to 40.3% with Lanczos 5, and writes this image out to MyFile2.jpg (with default Image Quality 80).
- LanzcosResize MyFile.jpg MyFile2.jpg –l3 –size 1024×768 –quality 30. Resizes MyFile.jpg to exact dimensions 1024x.768 with Lanczos 3, writing the output to MyFile2.jpg with specified JPEG Quality 30%.
About the Lanczos Resize Algorithm
The Lanczos Resize algorithm is a multi-CPU algorithm that resizes your image in 192-bit floating point. It runs very fast and is one of its nice features.
About Lanczos Types
Different Lanczos Types are great for different things:
- Lanczos 2. This is a good general resizing option. It is more like a bilinear resize and can avoid edges and artifacts.
- Lanczos 3. Lanczos 3 is a sharp resizing, and is the best option for downsizing images. It keeps sharp and avoid artifacting.
- Lanczos 5. Lanczos 5 is even sharper than Lanczos 3, and is the best option (imho) for making an image larger. Using Lanczos 5 to make images smaller is also a great option, and will create very sharp images; however, you may see some artifacts.
- Lanczos 8. Lanczos 8 is a great option, too. It is sharper than Lanzcos 5, and is great at keeping small details that even Lanczos 3 or 5 might miss. However, watch for “ringing” artifacts/ghosting with Lanczos 8.
The Jpeg Quality of the resizing is set to the highest quality, 4x4x4. This creates slightly larger files, but keep the color fidelity and definition very high. Most image editors, for example, tend to use 4x2x2, which does reduce details.
LanczosResize may be found at www.sagelighteditor.com/LanczosResize.exe and is about 400k in size.
It runs on Windows in Console mode and may be used in batch files for resizing.
LanczosResize.exe is free to use for non-commercial purposes and may not be included or used as part of any distributed program. It is for personal use only.
If you wish to use it for professional uses, or in a distributed package, write me at email@example.com
There is no warranty. It is a free program with no promises, as with all free programs. I have tested it and it runs great on my system.
As mentioned, LanczosResize is a prototype and a test for a larger set of available functions I am looking at releasing; perhaps as a hybrid of free functions for personal use, and something with a licensing fee for professional/distribution usage.
I’m also looking at the idea of distributing free programs and making income solely on donations. Let me know what you think about that, too.