Simple algorithms for adjusting image temperature and tint

I’ve already talked at length about converting a temperature (in Kelvin) to an RGB triplet. But what if you simply want to adjust an image’s temperature, without caring about the specifics of it?

Here’s how:

Given a temperature adjustment on the range -100 to 100,
 apply the following adjustment to each pixel in the image:

r = r + adjustmentValue
g = g
b = b - adjustmentValue

As with any additive RGB adjustment, you’ll need to manually clip the output values to the [0, 255] range.

Here’s a sample of the output, as implemented in the latest development build of my open-source photo editor. Note the temperature slider at the bottom of the screen. Because I find the -100 to 100 range to be a bit too strong, I actually divide the adjustment value by 5, thus limiting the actual adjustment value from -20 to 20:

temp_tint_base_image
Base image, courtesy of http://en.wikipedia.org/wiki/Great_wall
Temperature at max value (+20)
Temperature at max value (+20). Note the warmer tones.
Temperature at min value (-20)
Temperature at min value (-20). Note the cooler tones.

Pretty simple!

Because temperature and tint adjustments are usually provided together, here’s the code for basic tint adjustments. It’s even simper than temperature:

Given a tint adjustment on the range -100 to 100, 
 apply the following adjustment to each pixel in the image:

r = r 
g = g + adjustmentValue
b = b 

Sample output, using the same sample image from above (note the tint slider at the bottom):

Tint at max value (+20).  Hard to tell as the image is already very green, but the green has actually been ramped up further.
Tint at max value (+20). Hard to tell as the image is already very green, but the green has actually been ramped up further.
Tint at minimum value (-20).  Note the magenta color cast.
Tint at minimum value (-20). Note the magenta color cast.

This might be the simplest image processing algorithm I’ve ever posted… :)

PhotoDemon 6.2 beta live – testers welcome!

(Apologies for the dearth of blog posts over the past few months. The holidays always throw off my schedule, and it takes some time to get things back in order. I’ll try to make more time for articles!)

A new version of PhotoDemon includes an overhauled interface, lots of new tools (including cool things like Content-Aware resize), WebP and JPEG-XR support, and so much more.  Get it here.
The latest version of PhotoDemon includes an overhauled interface, cool new tools (like Content-Aware resize), WebP and JPEG-XR support, and so much more. Get it here.

A new version of PhotoDemon is about ready to release, and anyone who can help give it a final round of testing is most appreciated. Download the 6.2 beta here:

http://www.photodemon.org/downloads/PhotoDemon_6.2_beta.zip

The announcement article on photodemon.org contains a full run-down of all the new features, but let me mirror a few here for the curious:

Brand-new interface

PD_6-2-beta

The old MDI “floating-window” interface is gone for good. In its place is a sleek, lightweight tabbed interface.

Color-Managed Workflow

Color_Managed_Workflow

This was a huge project, and an exciting addition for both casual and professional users. PhotoDemon now provides a fully color-managed workflow across the entire program (including the main viewport, all tool dialogs, and even small things like color selection dialogs).

New color selector

PhotoDemon_Color_Selection

Major improvement over the stock Windows color selection dialog (which hasn’t changed in 20 years). Many thanks to the open-source photo editor GIMP, whose color selector served as the primary inspiration for this one.

Comprehensive Resize options

PhotoDemon_Resize_Dialog

In past versions, PhotoDemon always required you to resize images using pixel values – but no more! All resize dialogs (Image Resize, Canvas Resize, etc) now support resizing by pixels, percent, or physical units (inches, cm).

All-new JPEG export dialog

PhotoDemon_Export_JPEG_Final

PhotoDemon_Export_JPEG_Final_Metadata

As the most common image format, JPEGs deserve special consideration. PhotoDemon’s new JPEG export dialog provides many new features, including the ability to have the software automatically determine an appropriate quality setting for you.

WebP and JPEG-XR support (import and export)

I don’t know if anyone uses these formats, but they’re there if you need ’em!

New Autosave feature

PhotoDemon_Autosave_Dialog

New Content-Aware Resize tool

Initial image, courtesy of Wikipedia (http://en.wikipedia.org/wiki/File:Broadway_tower_edit.jpg).
Initial image, courtesy of Wikipedia (http://en.wikipedia.org/wiki/File:Broadway_tower_edit.jpg).
Image resized using a standard resize algorithm.  Note the undesirable stretching.
Image resized using a standard resize algorithm. Note the undesirable stretching.
The same image, resized using a content-aware algorithm.  Uninteresting features (like sky and grass) have been shrunk preferentially, leaving the interesting features (person, castle) intact.
The same image, resized using a content-aware algorithm. Uninteresting features (like sky and grass) have been shrunk preferentially, leaving the interesting features (person, castle) intact.

Content-aware resize is a cutting-edge technique for resizing images without distorting their contents. It was recently added to PhotoShop in version CS4, and nearly all free photo editors lack a comparable tool – but not PhotoDemon!

Improved tool previews

updated vignetting tool

Tool dialogs now provide an option to toggle between “fit whole image on screen” and “show image at 100%”. When showing the image at 100%, the image can be click-dragged, so even large images can be fully inspected. Also, the preview tool now supports “click to set a center point” behavior when relevant.

Asynchronous image metadata handling

Parsing image metadata occupies a huge chunk of the image load process. To improve performance, metadata handling is now completely asynchronous, meaning it will operate in parallel with the rest of the image loading process.

Improved Screen Capture tool

PhotoDemon_Screenshot_Dialog

Individual program windows can now be selected from a list, with or without their window decorations (titlebar, borders, etc).

And lots more…

Check out the official beta announcement at photodemon.org for a full list of updates and improvements.

PhotoDemon 6.0 is now live at photodemon.org

The final splash screen for version 6.0.  Thank you again to all the talented contributors that made this release possible!
The final splash screen for version 6.0. Thank you again to all the talented contributors that made this release possible!

After a successful (and relatively bug-free!) beta testing session, PhotoDemon 6.0 has been deemed “ready for mass consumption”. Normally this is where I would put a download link, but let me instead refer you to the new home of all things PhotoDemon: photodemon.org

I thought it was finally time for PD to get its own online home, and photodemon.org is the result. The site still has a few pieces left to assemble (most notably the Features section, which is only about half done), but I didn’t want that to delay the availability of 6.0’s release.

You can download version 6.0 from the “Downloads” section of the new site, or from this direct link:

Download PhotoDemon 6.0 (.zip file, 6.3 mb)

Functionally, this release is very similar to the 6.0 beta that launched two weeks ago. The primary changes from the beta are miscellaneous bug fixes, performance improvements, and cosmetic adjustments.

If you are upgrading from version 5.4, you’re going to notice a lot of new things! You can get a full write-up of all the improvements here, or if you’re in a hurry, here is the abbreviated list of updates:

  • All tools now support save/load presets, reset to default, randomize, and automatic save/load of last-used settings.
  • Italian language support.
  • Vastly improved support for non-US locales and non-English users.
  • Advanced selection tools, including rectangular, elliptical, and line selections.
  • All selection types now support feathering, live move/resize, interior/exterior/border types, and antialiasing.
  • Selection actions are fully integrated into Undo/Redo, and selections can be saved to disk.
  • Full preservation of all types of image metadata (EXIF, XMP, IPTC, etc). Metadata can be browsed via a new metadata browser.
  • Official RAW image format support; more than 20 RAW filetypes are now supported.
  • Three new blur tools: motion, radial, and zoom blur. Also, big improvements to Gaussian and Box Blur.
  • A new chroma key (“green screen”) tool with performance comparable to professional tools, including full support for edge blending.
  • New Perspective tool, with support for forward and reverse transforms.
  • New Photo Filter tool, with support for 50 digital photo filters (Wratten-type).
  • New Curves tool. Supports adding, moving, and removing an unlimited number of nodes.
  • New Channel Mixer tool.
  • New Canvas Resize tool.
  • New Spherize tool (for wrapping images around spheres).
  • New Vibrance tool.
  • New Pan and Zoom, Poke, Shear, and Squish distortion tools.
  • A new Language Editor for translators.
  • New variable-strength Sharpen tool.
  • New Oil Painting tool.
  • Many improvements to the Batch Wizard, including dedicated options for batch resizing.
  • Minor improvements to many tools, including polar coordinate conversion, wave distort, ripple distort, figured glass, tile image, posterize, rotate, custom filters, histogram, resize.
  • Any tool with a “color” option now allows you to pick a color directly from the image by clicking the preview.
  • Much better support for high-DPI screens, including tablets.
  • Support for transparent clipboard images, allowing you to move layered images between GIMP and PhotoDemon.
  • Filters and other long-running actions can now be canceled mid-action by pressing ESC.

Acknowledgments

This 6.0 release represents six months of hard work from a variety of contributors. While I am very grateful to all of PhotoDemon’s talented contributors, a few deserve special mention. Thank you to:

  • Audioglider for contributing three new tools: Channel Mixer, Vibrance, and Exposure. Audioglider also reported a number of issues, and motivated me to implement preset support for every PD tool.
  • Frank Donckers for again providing the German, French, and Dutch translations, and for contributing many pieces of code to the new Language Editor, including the Google Translate interface. Amazing stuff.
  • GioRock for the Italian translation, and for detailed testing of many small translation items. It takes a ton of work to get all of PD’s text translating properly, and GioRock debugged many items for me, which benefits users of every language.
  • Kroc Camen for a new IDE-safe mouse interface class, derived from his own open-source VB project. Kroc also reviews many of PD’s individual commits, where he catches many small items I overlook.
  • Robert Rayment for helping me profile and optimize a number of PD’s more taxing functions, and for many suggestions on tweaks and improvements. Many of the performance improvements available in this new version are a result of Robert’s help. Please check out his own VB image editor if you can.

Enjoy!

I hope you enjoy version 6.0. If you have any feedback, please send me a message. I’d love to hear from you.

 

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!

PhotoDemon 6.0 beta is live

Chroma key (green screen) is one of many new tools in this release.
Chroma key (green screen) is one of many new tools in this release.

Download

Remember: if you’re an advanced user, you never have to wait for a beta release. You can always download PhotoDemon’s latest development release from its GitHub page (source code), or from this nightly build permalink (program only).

PhotoDemon is funded by donations from users like you.
Please consider a small donation to fund development and to help me support my family.
Even $1.00 helps. Thank you!

Overview

It’s taken nearly six months, but PhotoDemon 6.0 is finally ready for release. I’ve already talked about some of the great features this release includes, like powerful selection tools, metadata (EXIF) support, Curves and other new tools, so I’d recommend glancing through the linked article if you’re curious.

Since that article, a number of other features have been added or improved:

  • All tools now support save/load presets, reset to default, randomize, and automatic save/load of last-used settings. These items are all accessible from a new “command bar” at the bottom of each tool dialog.
  • From left-to-right, the command bar includes buttons for: reset, randomize, saved presets, and save current settings as preset.  Last-used settings are automatically saved and loaded by the dialog.
    From left-to-right, the command bar includes buttons for: reset, randomize, saved presets, and save current settings as preset. Last-used settings are automatically saved and loaded by the dialog.
  • Three new blur tools: motion, radial, and zoom blur. These tools outperform similar tools in GIMP and Paint.NET.
  • PhotoDemon's new radial blur tool is 4x faster than Paint.NET's, and 30x faster then GIMP's - and at high angles, it produces significantly better output.
    PhotoDemon’s new radial blur tool is 4x faster than Paint.NET’s, and 30x faster then GIMP’s – and at high angles, it produces significantly better output.
  • Much faster Gaussian and Box blur tools (20x improvement!)
  • The updated Gaussian Blur tool now provides quality settings for improved performance.  For most photos, the difference between "good" and "best" will be indistinguishable, but "good" will be some 20x faster.
    The updated Gaussian Blur tool now provides quality settings for improved performance. For most photos, the difference between “good” and “best” will be indistinguishable, but “good” will be some 20x faster.
  • A new chroma key (“green screen”) tool with performance comparable to professional tools, including full support for edge blending. Find it in the Image -> Transparency -> Make color transparent menu.
  • Before color removal; image courtesy http://dimula73.blogspot.com/2013/03/new-user-interface-for-krita-color-to.html
    Before color removal; image courtesy http://dimula73.blogspot.com/2013/03/new-user-interface-for-krita-color-to.html
    After color removal.  Note that the tool creates a 32bpp image, which you can then composite using any photo editing software.
    After color removal. Note that the tool creates a 32bpp image, which you can then composite using any photo editing software.
  • A new Language Editor makes contributing new translations fast and easy.
  • The new Language Editor makes it easier than ever to get involved in translation.  Please contact me if you can help!  (You will receive full credit for your work.)
    The new Language Editor makes it easier than ever to get involved in translation. Please contact me if you can help! (You will receive full credit for your work.)
  • New variable-strength Sharpen tool
  • Previously, PhotoDemon only provided set "Sharpen" and "Sharpen More" functions.  The new tool allows for floating-point adjustments, which allow for much more nuanced fixes.  (Unsharp Masking is still available too, obviously!)
    Previously, PhotoDemon only provided set “Sharpen” and “Sharpen More” functions. The new tool allows for floating-point adjustments, which allow for much more nuanced fixes. (Unsharp Masking is still available too, obviously!)
  • New Oil Painting tool
  • Same photo as the screenshot at the top of this page, but oil-ified.
    Same photo as the screenshot at the top of this page, but oil-ified.
  • Minor improvements to many tools, including polar coordinate conversion, perspective correction, wave distort, ripple distort, figured glass, tile image, posterize, rotate, custom filters, histogram.
  • The perspective tool now supports both forward and reverse transforms.  Reverse transforms allow you to simply trace a crooked object, and have it automatically straightened by the program.
    The perspective tool now supports both forward and reverse transforms. Reverse transforms allow you to simply trace a crooked object, and have it automatically straightened by the program.
    The histogram offers new render options, which can be helpful for identifying areas of channel overlap.
    The histogram offers new render options, which can be helpful for identifying areas of channel overlap.
  • Any tool with a “color” option now allows you to pick a color directly from the image by clicking the preview.
  • Much better support for high-DPI screens, including tablets.
  • Faster viewport rendering for 32bpp images.

Again, these new features are only a fraction of what 6.0 includes. Please check out the 6.0 preview article for news on all the other new tools and improvements.

Acknowledgments

This 6.0 release represents six months of hard work from a variety of contributors. While I am very grateful to all of PhotoDemon’s talented contributors, a few deserve special mention. Thank you to:

  • Audioglider for contributing three new tools: Channel Mixer, Vibrance, and Exposure. Audioglider also reported a number of issues, and motivated me to implement preset support for every PD tool.
  • Frank Donckers for again providing the German, French, and Dutch translations, and for contributing many pieces of code to the new Language Editor, including the Google Translate interface. Amazing stuff.
  • GioRock for the Italian translation, and for detailed testing of many small translation items. It takes a ton of work to get all of PD’s text translating properly, and GioRock debugged many items for me, which benefits users of every language.
  • Kroc Camen for a new IDE-safe mouse interface class, derived from his own open-source VB project. Kroc also reviews many of PD’s individual commits, where he catches many small items I overlook.
  • Robert Rayment for helping me profile and optimize a number of PD’s more taxing functions, and for many suggestions on tweaks and improvements. Many of the performance improvements available in this new version are a result of Robert’s help. Please check out his own VB image editor if you can.

Known bugs

  • EXIF data is not maintained with certain combinations of preferences (delay loading EXIF + export full data when saving). This is caused by a metadata caching issue, and will be fixed by release. Fixed!
  • ExifTool plugin is slightly out of date. It will be updated to its latest version upon 6.0’s release. Fixed!
  • Metadata menus sometimes become disabled even when metadata is available. This will be fixed by release. Fixed!
  • OK and Cancel buttons are not currently translated. This will be fixed by release. Fixed!
  • Some hotkeys don’t fire unless the main form is first clicked. This is a known problem with VB, and will hopefully be fixed by release. Fixed!
  • Master language file is missing a few minor text entries. This will be fixed by release.

The beta version was released before these small items were fixed, so it still contains these bugs. Developers can download updated source code, with these fixes, from GitHub.

Official release timeline

Barring any major bugs, the official 6.0 release should happen within several weeks. Feature-wise, it will be identical to this beta release. The only changes will be minor bug fixes and performance improvements. Automatic update notifications for existing PhotoDemon installs will also go live at that point.

Blur Filter performance: PhotoDemon vs GIMP vs Paint.NET

(Note before I begin: the PhotoDemon 6.0 beta should be live by the end of this week. Sorry it took so long to prepare!)

See what kind of fun charts we get to discuss?  And here I thought the days of 17-minute photo editing actions died with the Pentium III...
See what kind of fun charts we get to discuss? And here I thought the days of 17-minute photo editing actions died with the Pentium III…

The latest nightly build of PhotoDemon (download it here) includes a bunch of new and improved blur filters. Blur filters are among the most computationally demanding filters in a photo editor, because for each pixel in an image, a bunch of other pixels must also be examined in order to calculate the blur. (Blurs generally work by averaging together groups of pixels. Motion blur averages pixels in a line, radial blur averages pixels in an arc, and normal blur averages pixels in a box or circle shape.)

As a simple example, consider a basic blur with a 200 pixel radius, applied to a 10 megapixel digital photo. For each pixel in the photo (all ten million of them), an area of 200 pixels in each direction must be averaged together. Using a simple box blur, that means a box of 200 pixels left, right, up and down must be tallied (for a net area of 400 * 400, or 160,000 pixel comparisons) in order to calculate the blur. Thus, such an algorithm would require:

10,000,000 pixels * 160,000 calculations per pixel = 1.6 trillion total calculations

Even on a modern processor, that’s an enormous undertaking. Fortunately, mathematicians and coders have developed many clever ways to optimize blur functions. Many of these optimizations appear in the newest PhotoDemon build, so I thought it would be fun to speed-test four of PhotoDemon’s blur tools against two other free photo editors: GIMP and Paint.NET. The results were surprising enough that I thought them worth sharing.

A brief overview of each photo editor:

  • PhotoDemon: open-source, written in VB6, nightly build 893 (6.0 beta)
  • GIMP: open-source, written primarily in C, v2.8.6
  • Paint.NET: closed-source, written primarily in C# (and the .Net framework, per the name), v3.5.11

As benchmarking goes, this was very informal. PhotoDemon reports timing automatically in nightly builds, but for GIMP and Paint.NET I had to resort to using a stopwatch. Normally this is a terrible idea, but the algorithms involved take a very long time to run, so a stopwatch was sufficient for broad timing. (10ths of a second don’t matter much when an algorithm takes twenty minutes to finish…)

All tests were done on Windows 7 (64-bit), on my Core i5 650 (3.2ghz) desktop PC with 8gb of RAM. My PC was middle-of-the-road when I bought it back in 2010, so I’d consider reasonably representative of an “average” PC. All the tools in question appear to be heavily CPU-bound anyway, so it’s doubtful newer processors or more cores would make a meaningful difference.

The test photo I used was a 10 megapixel photo, 3872×2592 specifically, in JPEG format:

10 megapixel test photo

With the exception of some very long timings (10+ minutes), all timings were checked twice to make sure results were representative. Very long ones were only checked once due to the wait involved, though I did initiate a second attempt just to make sure my PC wasn’t acting up. (It wasn’t.)

Here are the timing results for four separate blur types, with some notes on my implementation, and what I know or can potentially infer about GIMP and/or Paint.NET’s implementations.

(Due to the large size of the images involved, I saw no reason to upload the output images of each test. Anyone interested can easily reproduce this test on their own PC with images of their choosing.)

Gaussian Blur

Two notes - PhotoDemon used the "good" quality setting, which is a Gaussian estimation using a modified 3x box blur, and GIMP used the IIR method.
Two notes – PhotoDemon used the “good” quality setting, which is a Gaussian estimation using a modified 3x box blur, and GIMP used the IIR method.

Gaussian Blur provides an excellent starting point. Gaussian blur works by averaging a square chunk of pixels, and giving pixels close to the center more weight than pixels far away. It is the most common type of blur tool in photo editing software, probably because its results are aesthetically pleasing, and it is an easy blur function to optimize.

Instead of a naive approach, which would involve the 1.6 trillion calculations mentioned above, most photo editors implement Gaussian Blur using a separable implementation, which cuts the calculations to a much more pleasant 8 billion calculations. Unfortunately, 8 billion calculations is still a lot. (PhotoDemon’s “best quality” option on its Gaussian tool applies a pure Gaussian using separable kernels. On large images, it’s slow. Very slow.)

An even faster approach takes advantage of a neat mathematical relationship between box filters and Gaussian filters: if you keep applying a box filter to a set of data, the result will eventually approach a Gaussian distribution. (Excellent charts available here, courtesy of Nghia Ho.) The Central Limit Theorem shows that repeating a box blur three times results in a function that’s ~97% identical to a true Gaussian.

PhotoDemon uses this as the basis for its three quality settings for Gaussian blur (good, better, and best). Good is a 3x box blur approximation, Better is a 5x, and Best is a true Gaussian. For the chart above, I used the “good” setting because it is by far the fastest. (Note that there’s a bit more to it than just repeating a box blur – how you calculate the box blur size matters; I use a variation of the W3 recommendation available here.)

Take-home message: GIMP’s IIR implementation is excellent – very fast, and it produces a true Gaussian, no estimations. PhotoDemon is surprisingly competitive for a single-threaded VB6 app. Paint.NET’s Gaussian is quite poor both in quality and final result. Its resulting blur is muddier than a true Gaussian, and much slower than you’d expect for a box-blur approximation… so I honestly have no idea how they’ve implemented it.

Motion Blur

PhotoDemon used "Quality" mode instead of "Speed", meaning bilinear interpolation was applied to the rotated image.  No extra options are available for this tool in GIMP or Paint.NET.
PhotoDemon used “Quality” mode instead of “Speed”, meaning bilinear interpolation was applied to the rotated image. Also, “blur symmetrically” was checked. No extra options are available for this tool in GIMP or Paint.NET.

Motion blur is a bit more problematic than Gaussian blur, because it doesn’t work in a square pattern. A naive approach would have you use something like Bresenham’s algorithm on each pixel, tracing a line at the specified angle and averaging interpolated values as you go.

A much better approach is to simply rotate the image by the requested angle, apply a (very fast) horizontal blur, then rotate the image back into place. If you use a fast rotation algorithm (like the famous 3-shear technique), this can make motion blur very quick.

My PhotoDemon implementation does not use the fast 3-shear technique; it uses a naive, geometric rotation (reverse-mapped) with bilinear interpolation. I expected this to make it quite a bit slower than comparable tools in GIMP and Paint.NET, but I was surprised to discover that both software packages are… well, pretty damn terrible.

Based on a brief perusal of GIMP’s source code, they appear to use the naive Bresenham approach, which explains why it’s so slow.

Once again, Paint.NET’s execution time makes no sense to me. For a software package that claims: “extensive work has gone into making Paint.NET the fastest image editor available“, methinks they need a bit more “extensive work” on this particular tool…

Radial Blur

As before, PhotoDemon uses the "quality" setting for bilinear interpolation.  Paint.NET was applied at quality setting 2 out of 5, the default setting.  (This results in a noticeably lower-quality image than PhotoDemon or GIMP.)  GIMP does not provide any additional options for this tool.
As before, PhotoDemon uses the “quality” setting for bilinear interpolation. Paint.NET was applied at quality setting 2 out of 5, the default setting. GIMP does not provide any additional options for this tool.

And so we move to Radial Blur, where we find a surprising role reversal: Paint.NET gives a much better showing here, while GIMP turns in the worst performance yet. Again, a brief look at GIMP’s source code for this function shows a questionable nested-loop approach to the problem. Tracing an arc-like path for each pixel is a bad idea, and while bilinear interpolation is used to improve the output quality – same as PhotoDemon – the time required makes this tool pretty much unusable.

PhotoDemon’s implementation is nothing particularly special, which makes its relative performance so surprising. I use a well-known trick where I convert the image to polar coordinates, apply a horizontal blur, then convert the image back to Cartesian coordinates. A small amount of image quality is lost by the two coordinate conversions, but because we are blurring the image anyway, this doesn’t matter much. That said, for small angles (< 5 degrees), both GIMP and Paint.NET produce better-looking output. At larger radii, however, PhotoDemon's is much better. Both GIMP and Paint.NET produce Moire patterns, presumably from sampling at discrete intervals, while PhotoDemon’s output is clean and smooth. This can probably be fixed in Paint.NET by using a higher quality setting, but quality setting 2/5 was already slow enough!

The top-left corner of the image after PhotoDemon's radial blur.  Buttery smooth, and accurate edge handling.
The top-left corner of the image after PhotoDemon’s radial blur. Buttery smooth, and accurate edge handling.
Same corner, but from Paint.NET's radial blur.  Nasty Moire patterns, and problematic handling in the corner - from an algorithm that took 4x longer to run.
Same corner, but from Paint.NET’s radial blur. Nasty Moire patterns, and problematic handling in the corner – from an algorithm that took 4x longer to run.

Zoom Blur

No, that huge green bar is not an error.  GIMP took a whopping 17 minutes to render a 200px zoom blur.  PhotoDemon's "traditional" mode was used to provide comparable output.  Paint.NET does not offer any specialized options for this tool.
No, that huge green bar is not an error. GIMP took a whopping 17 minutes to render a 200px zoom blur. PhotoDemon’s “traditional” mode was used to provide comparable output. Paint.NET does not offer any specialized options for this tool.

Last up is Zoom Blur, and we have a surprising winner! Paint.NET’s zoom blur implementation is excellent – great quality, very fast, and overall a huge improvement from their other blur tools. I have no idea why Zoom Blur is significantly faster than their Gaussian Blur implementation at a comparable pixel size, so I can only assume that some kind of specialized optimizations have been added. Nice work, Paint.NET team!

GIMP… I don’t even know what to say. It’s possible that I triggered some sort of problem with GIMP’s tile-based processing system, because there is no good way to explain a 17-minute processing time for such a straightforward function. Even a naive implementation shouldn’t take anywhere near that long. Their implementation has loops nested five-deep (dear god), and while bilinear interpolation is used to improve output, that algorithm is so poorly written that I frankly think they should consider removing it completely. Even at very low distances, rendering takes forever. The original copyright date on the source file is 1997, so perhaps someone familiar with GIMP’s internals should give this one a second look.

PhotoDemon uses the same trick here as with radial blur. The image is converted to polar coordinates (with swapped x and y values compared to the radial blur conversion), a horizontal blur is applied, then the image is converted back. Again, there is quality loss at low values, and both Paint.NET and GIMP provide better-quality output at very small radii. To mitigate this, I provide a second style on that dialog, which uses an iterative image-sized alpha blend to generate a blur. One of the neat things about that approach is that the image can be zoomed-out as well as zoomed-in.

I doubt there is a legitimate use for zoom-blur-outward like this, but it wasn't any extra work to implement.  :)
I doubt there is a legitimate use for zoom-blur-outward like this, but it wasn’t any extra work to implement. :)

Conclusions

Blur algorithm performance is hugely variable in both GIMP and Paint.NET. I’ll admit – I find it a bit amusing that my little PhotoDemon project, written with a 15-year-old programming language and compiler, outperforms them so handily in multiple areas, despite my implementations being generally lazy, single-threaded, and heavily CPU-bound. I also call “bullshit” on Paint.NET’s claim about “extensive work going into making Paint.NET the fastest image editor available.” I think the Paint.NET team does great work, and their software is a wonderful improvement over many free and paid photo editors, but its performance is greatly lacking in a number of areas.

Then there is GIMP. While I am very grateful for their software, and have learned to love its many quirks, there’s no denying that whole swaths of its source code are in desperate need of a revamp. I imagine there is no point revisiting items like blur until they complete their migration to GEGL – perhaps then we will see big improvements in the performance of these various blur functions.

If there’s a take-home message to all this, it’s that algorithms will always be more important than programming languages. A well-written algorithm in a “slow” language will often outperform a poorly written algorithm in a “fast” language. VB6 may be forgotten and nearly dead, but I’m happy to see it staying competitive with the titans of the “free photo editor” world. :)

If you read the article all the way to here, I hope you’ll give PhotoDemon a look:

http://www.tannerhelland.com/photodemon/#download

For a free, open-source photo editor, it has a lot of nice features, and I can empirically state that it outperforms GIMP and Paint.NET in at least a few areas! (The current nightly build is pretty much how the next stable release (6.0) will look, minus a few minor bugfixes still to complete.)

How to compile zLib 1.2.8 (WINAPI / WAPI / STDCALL version)

This is not a full-blown article – just a quick HOWTO for people who require the latest version of zLib and want to use it from a language (like classic VB) that requires a standard WinAPI interface.

By default, zLib uses C calling conventions (CDECL). Gilles Vollant has helpfully provided an STDCALL version of zLib in the past, but his site only provides version 1.2.5, which dates back to January 2012. zLib is currently on version 1.2.8.

Gilles has contributed his WAPI fixes to the core zLib distribution so that anyone can compile it themselves. To do this, you will need to download:

Once both of those are downloaded (and updated, as VS 2012 will require you to install several service packs), follow these steps to compile zLib yourself:

  1. Extract the entire zLib file and navigate to the /contrib/masmx86 folder. Open the “bld_ml32.bat” file in a text editor.
  2. Add the “/safeseh” switch to both lines in that file (e.g. “ml /safeseh /coff /Zi /c /Flmatch686.lst match686.asm”). Then save and exit.
  3. Navigate to the /contrib/vstudio/vc11/ folder. Open the zlibvc.sln file in your newly installed Visual Studio 2012 Express.
  4. In the Solution Explorer (top-right by default), right-click “zlibstat” then select “Properties” at the bottom.
  5. Go to Configuration Properties -> C/C++ -> Preprocessor, and in the Preprocessor Definitions line remove “ZLIB_WINAPI;” (don’t forget to remove the trailing semicolon).
  6. Now, we need to fix a recently introduced problem that relies on Win8 functionality. In the Solution Explorer, navigate to zlibvc -> iowin32.c. Double-click to open the file.
  7. Find the line of text that reads “#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)”. Change this line to “#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY_DESKTOP_APP, WINAPI_PARTITION_APP)”. (Thanks to this link for this fix.)
  8. zLib uses a Version number declaration that can cause the build process to fail. To fix this, go back to the Solution Explorer, then navigate to zlibvc -> zlibvc.def. Double-click to open.
  9. Change the line that reads “VERSION 1.2.8” to read “VERSION 1.28”.
  10. Finally, go to the Build -> Configuration Manager menu and change the Active Solution Configuration to “Release”.
  11. Exit that window and press F7 (or click the Build -> Build Solution menu). The project should successfully build.
  12. You can find your newly compiled zlibwapi.dll file in the /contrib/vstudio/vc11/x86/ZlibDllRelease/ folder.

PhotoDemon 6.0 preview and progress report

PhotoDemon's new splash screen.  I'd say this is a "huge" improvement over the old one, but that might be understating it... :)
PhotoDemon’s new splash screen. I’d say this is a “huge” improvement over the old one, but that might be understating it…

overview

It’s been awhile since I posted any news on PhotoDemon, but not because work has slowed – just the opposite, in fact! The development version of PD is cranking ahead full-steam, and thanks to a number of outside contributors, the next version will include a wider set of improvements than any previous version. There’s still quite a bit of testing and fine-tuning to do, so this article does not include a downloadable beta release – rather, the article is meant to serve as a preview of the upcoming 6.0 release and all the cool new features it provides. (Of course, developers or anyone with access to Visual Basic 6.0 can compile the latest version themselves by visiting PhotoDemon’s GitHub page. New testers and contributors are always welcome!)

First, an explanation on why the next PhotoDemon release will be version 6.0 instead of the expected 5.6. The next release will break backward compatibility with a number of PhotoDemon files, including any saved macros or filters. This break is necessary to implement a large overhaul of PhotoDemon’s internals – an overhaul that makes the program faster, smaller, more stable, and much easier to develop and maintain. The goal is to have all of PhotoDemon’s specialized file formats (including macros) use XML for storage. This allows both users and other software developers to read and edit PhotoDemon files from any general-purpose text editor. This change will also make it much easier to add new macro features without breaking old macro files. (The current macro format was developed over a decade ago, when the program was only meant for personal use, and it is extremely flimsy and difficult to extend – hence the need for a redesign.)

The downside of this change is that any current macros will need to be re-recorded in version 6.0, as version 4.X and 5.X macros will no longer be supported. I apologize for this inconvenience, and I promise to do my best to avoid breaking backward compatibility in the future.

The 6.0 release will also include important interface changes – such as a redesigned main menu and tool window – further supporting the switch to a new major version number, and for developers, the program’s central action processor has been redesigned from the ground up, making it easier than ever to get involved in development.

So with that out of the way, let’s talk about the good stuff, namely: what’s coming in 6.0? Here is a list of features and updates that are already finished and available in the current development build (again, downloadable at https://github.com/tannerhelland/PhotoDemon).

Italian language support

Courtesy of talented contributor GioRock is a new Italian language option for PhotoDemon. Many thanks to GioRock for this huge contribution.

Other internationalization improvements

With the help of GioRock and Frank Donckers (you may remember Frank as the brilliant developer behind PhotoDemon’s language translation engine), a number of other improvements are now available for international PhotoDemon users:

  • The comma “,” is now supported as a decimal separator in all tools. Previously, use of a comma could lead to critical errors.
  • Translated text is now automatically resized if it is larger than its tool window. This helps text in verbose languages remain fully readable.
  • Translations that span multiple lines (such as long tooltips) are now automatically handled by the program. This reduces the burden on translators to manually fit translated text longer than its English equivalent.
Here is the Options panel in full Italian.  The text of the bottom checkbox on the right-hand panel originally extended past the edge of the dialog, but PhotoDemon has detected that and shrunk the text accordingly.  This requires no work on the part of the translator!
Here is the Options panel in full Italian. The text of the two checkboxes on the right-hand panel originally extended past the edge of the dialog, but PhotoDemon has detected that and shrunk the text accordingly. (This required no work on the part of the translator!)

New feature: advanced selection tools

The new elliptical selection tool, with live feathering (feathering is the softened selection edges).
The new elliptical selection tool, with live edge feathering.

PhotoDemon 6.0 includes a completely redesigned selection tool engine. At present, the following dedicated selection tools are available:

  • Rectangular and Square selections (with optional rounded corners, including variable corner radii)
  • Elliptical and Circular selections
  • Line selections: unique to PhotoDemon, this tool allows you to select a line-shaped area, very helpful for things like tilt-shift effects (see below)
PhotoDemon's line selection tool was combined with Gaussian Blur to simulate this fake miniature photograph of the city of Jodhpur.  (Photograph and concept taken from this Wikipedia article.)
PhotoDemon’s line selection tool was combined with Gaussian Blur to simulate this fake miniature photograph of the city of Jodhpur. (Photograph and concept taken from this Wikipedia article.)

Each selection tool supports the following features:

  • Live selection coordinate and size display
  • On-canvas resizing by click-dragging nodes
  • Selections can be nudged or moved via text entry
  • Shift can be held to lock a 1:1 aspect ratio (e.g. squares or circles)
  • Live smoothing options: none, antialiased, or variable radius feathering (live feathering is only available on Windows 7)
  • Live selection types: interior, exterior, or bordered, with live border radius selection

In addition to these dedicated tools, a new Selection menu is available with additional selection-related features.

PhotoDemon's new Select menu
PhotoDemon’s new Select menu
  • Select All and Select None
  • Invert Selection (switch selected and un-selected pixels, with full feathering support!)
  • Grow/Shrink Selection
  • Border selection, which takes the current selection and selects only its border
  • Feather and sharpen selection
  • Load and save selections

Thanks to the selection engine redesign, these features will automatically work with future selection tool implementations, including polygon/free-draw and “magic wand” selections.

Another huge improvement is integrating all selection actions into the Undo/Redo engine. If you create, move, resize, or apply any other action to a selection, you can now Undo/Redo that operation.

Selections are now fully integrated into the Record Macro tool.

Copy and Crop now support selections of any shape, making it trivial to crop circular or rounded-rectangle regions, or copy them for use in another program. (Feathered selections are automatically converted to 32bpp images, with the feathering applied in the alpha channel.)

Finally, the core Selection tools have been rewritten to use vector coordinates. This means that selections loaded from file are automatically resized to fit the current image, making them extremely useful for Batch Processing operations.

New image metadata (EXIF, XMP, IPTC) support

PhotoDemon now includes the marvelous ExifTool project as an optional plugin. ExifTool is the most comprehensive image metadata handler currently available, and PhotoDemon makes full use of its ability to handle every known type of image metadata, from the popular EXIF format (used in JPEGs) to obscure maker notes for all major DSLR brands.

PhotoDemon's new custom-built Image Metadata browser.  This image is a RAW-format file from an Olympus DSLR.  ExifTool allows us to peruse all the custom Olympus data entries.
PhotoDemon’s new custom-built Image Metadata browser. The metadata in question comes from a RAW-format photo taken with an Olympus DSLR camera. Note that ExifTool allows us to peruse all the non-standard Olympus data entries.

A new integrated metadata browser automatically sorts metadata by category, and it allows the user to see actual or human-friendly metadata tags. The browser fully integrates with ExifTool’s multilanguage capabilities, sparing translators from any extra work!

When saving images, the Preferences manager now provides options for metadata embedding:

PhotoDemon's new metadata handling preferences.
PhotoDemon’s new metadata handling preferences.

Unique to PhotoDemon is a privacy-centric metadata option, which aims to remove any personally identifying metadata entries, like serial numbers or GPS coordinates. By default, the “preserve all relevant metadata” option is recommended, which will remove any metadata not relevant to a file format (such as removing maker notes when saving RAW files to JPEG), but retain all other metadata entries. Metadata can also be fully stripped from exported files.

Also fun is a new Image -> Metadata -> Map GPS Coordinates option, which becomes available if an image contains GPS data. This option will automatically map the photo’s location in Google Maps.

New tools: too many to mention!

As always, the next release will include a host of new image editing tools. Here’s a small sampling of the latest additions to PhotoDemon’s repertoire:

PhotoDemon's new interactive perspective correction tool.  Drag the corner nodes to re-visualize the image in real-time, allowing you to do things like fix crooked buildings, as in this photograph from a recent trip to San Francisco.
PhotoDemon’s new interactive perspective correction tool. Drag the corner nodes to re-visualize the image in real-time, allowing you to do things like fix crooked buildings, as in this photograph from a recent trip to San Francisco.
PhotoDemon's new Photo Filter browser.  To my knowledge, this is the most comprehensive collection of post-production Wratten filters in any software, ever.  The interactive photo filter browser provides 50 custom-built photo filters for fixing every possible lighting situation.
PhotoDemon’s new Photo Filter browser. To my knowledge, this is the most comprehensive collection of digital Wratten filters in any software, ever. The interactive photo filter browser provides 50 filters, allowing you to make an infinite number of post-production lighting adjustments.
PhotoDemon's new Curves tool.  It supports unlimited curve points, a live histogram overlay, removal of points by right-clicking them, and fully antialiased curve rendering.  In my opinion, this is the loveliest tool in the program, and the loveliest Curves dialog of any mainstream photo editor.
PhotoDemon’s new Curves tool. It supports unlimited nodes, removing nodes by right-clicking, a live histogram overlay, and fully antialiased curve rendering. In my opinion, this is the loveliest tool in the program, and the loveliest Curves dialog of any mainstream photo editor.
PhotoDemon's new Channel Mixer.  This tool comes courtesy of outside contributer audioglider, who contributes multiple tools to this release - please shower him with praise!  (The subject of this photo is the latest addition to my family, a beautiful Australian Shepherd / Shetland Sheepdog mix named Yosuke.)
PhotoDemon’s new Channel Mixer. This tool comes courtesy of outside developer audioglider, who built multiple tools in this release – so please shower him with praise! (The subject of this photo is the latest addition to my family, a beautiful Australian Shepherd / Shetland Sheepdog puppy named Yosuke.)
PhotoDemon finally includes a Canvas Resize tool.
PhotoDemon finally includes a Canvas Resize tool.
PhotoDemon's new Sphere tool lies more in the "Fun" category than the "Practical" one, but that's okay.  For a bit of extra style, the program can render matching background rays onto the canvas, as shown in the screenshot above.
PhotoDemon’s new Sphere tool lies more in the “Fun” category than the “Practical” one, but that’s okay. For a bit of extra style, the program can render matching background rays onto the canvas, as shown in the screenshot above.

For sake of brevity, I’ll forgo images of the rest of the new tools, namely:

  • Max/min channel
  • Pan and zoom
  • Poke
  • Shear
  • Squish
  • Vibrance (developed by audioglider)

Other improvements and additions for end-users

PhotoDemon's batch wizard now includes dedicated options for common batch operations, such as resizing.  The wizard has also been further streamlined to make batch processing as easy and quick as possible.
PhotoDemon’s batch wizard now includes dedicated options for common batch operations, such as resizing. The wizard has also been further streamlined to make batch processing as easy and quick as possible.
The Resize Tool has undergone a significant redesign.  Resampling options are now human-friendly, and several how-to-fit options are now provided when changing an image's aspect ratio.  This makes it possible to resize images to a new aspect ratio without unsightly distortion.
The Resize Tool has undergone a significant redesign. Resampling options are now human-friendly, and several how-to-fit options are now provided when changing an image’s aspect ratio. This makes it possible to resize images to a new aspect ratio without unsightly distortion.
When flattening an image with transparency (alpha channel), you can now select a background color.  Previously the software always defaulted to white.
When flattening an image with transparency (alpha channel), you can now select a background color. Previously the software always defaulted to white.
  • Transparent images can now be copied/pasted between PhotoDemon and other software. This means you can take an image with multiple layers in GIMP and paste it into PhotoDemon fully composited.
  • Official RAW image format support; more than 20 RAW filetypes are now supported.
  • 30-40% speed improvements to Gaussian Blur, Smart Blur, and Unsharp Masking thanks to an Integer-only rewrite of the blur engine.
  • Filters and other long-running actions can now be canceled mid-action by pressing ESC.
  • Revamped main window interface, as you can see in the screens above. The left-hand toolbar is now images-only, while the right-hand one has been expanded.
  • Better validation for all text controls. Invalid entries are automatically circled in red.
  • Alt+T will now let you switch between preview and non-preview modes in all tools.
  • Many miscellaneous bug fixes, optimizations, and other improvements. For a full list, see the commit log at https://github.com/tannerhelland/PhotoDemon/commits/master

Improvements and additions for developers and contributors

  • PhotoDemon can now provide timing reports for all actions passed through the central software processor. Simply enable the DISPLAY_TIMINGS constant when compiling.
  • New custom slider/text and up/down controls make it easy to utilize PD’s existing validation and translation abilities in your own tool dialogs.
  • A new string-based filter parameter class makes it easy to tie complex tools with many parameters into the software processor (and thus into recorded macros). No longer do you have to convert param lists to complex custom Variant embeddings.
  • PhotoDemon now includes a high-performance font rendering class, which makes custom font rendering (with AA) much easier to implement.
  • Dev builds, including build number, are now automatically detected by the program, making it easy to see which build you’re currently working with.
  • Support tools, including the custom plugin compressor and master translation file generator, are now synched to GitHub in the /Support subfolder.
  • A public histogram-generation routine is now available, so you can tap into PhotoDemon’s highly optimized histogram generator for any of your own tools.

Contributors, developers, and translators still welcome!

As always, PhotoDemon can never have enough external contributors, developers, and translators. If you can help with any aspect of the 6.0 release, don’t hesitate to get in touch. Many features in the 6.0 release wouldn’t be possible without outside help, and I’d love to add you to the ever-growing list of talented contributors that make PhotoDemon possible!

If you can’t contribute with coding or translations, donations are another great way to help. Thanks in advance for your small monetary contribution to this completely open-source project, which provides a full-featured photo editor (comprising 60,000 lines of code and more than 50,000 words of translated text in five languages) completely free of charge.

PhotoDemon 5.4.1 is now live

PhotoDemon 5.4.1 provides fixes for several issues found in version 5.4 (released two days ago). If you have automatic updates enabled, you will automatically be notified up the update, or you can manually download it here.

5.4.1 fixes the following bugs:

  • FIXED: Some controls do not display text correctly on Windows XP
  • FIXED: Some dialogs load very slowly when a translation is active
  • FIXED: Some edge detection methods fail to initiate when a translation is active
  • FIXED: Left-hand toolbox text formatting looks poor when a translation is active
  • FIXED: Tooltips not showing for picture box objects when a translation is active
  • FIXED: When the last-used folder in the batch process tool contains many images (1000+), the batch tool loads slowly on subsequent uses
  • FIXED: Minor typographical errors in translation files

This update also includes a few minor modifications and additions:

  • MODIFIED: In the batch process tool, when a selected image is removed from the batch list, its preview is now erased to prevent confusion
  • ADDED: further optimizations to translation engine. Program performance should now be much better while translations are active.
  • ADDED: batch process tool now displays the number of images in the current batch list

Once again, you can download the update here.

PhotoDemon 5.4 is live – now with German, French, and Dutch language support

Summary

PhotoDemon 5.4 is complete. New features include language support (German, French, and Dutch), a full-featured batch processing wizard, shadow/highlight correction, nine new distort tools, vignetting, median noise removal, JPEG and PNG optimization, and more. Download it here.

Kaleidoscope is probably the least practical (but most fun!) new tool in 5.4.  :)
Kaleidoscope is probably the least practical (but most fun!) new tool in 5.4. Also, German!

Highlight feature: support for multiple languages!

This is the biggest addition in version 5.4, and I can only claim partial credit for it. Primary credit goes to Frank Donckers, a fellow VB programmer who prototyped the initial translation engine for me. As if that isn’t incredible enough, Frank also supplied the translations for French, German, and Dutch (Flemish), so I owe him an enormous debt of gratitude. Thank you, Frank!

One of the neatest aspects of this feature is the ability to change the language at run-time via the Language menu. Unlike every program I have ever used, no restart is required. PhotoDemon will dynamically change the program’s entire language immediately, and if you change your mind, you can switch to any other language at any time.

I hope these three languages are only the beginning. If you speak a language other than English, please consider contributing a new PhotoDemon translation! No programming knowledge is required, and you will receive full credit for your work. Contact me for more details.

Nine new Distort-style tools

Add and remove lens distortion. Swirl. Ripple. Pinch and whirl. Waves. Kaleidoscope. Polar conversion (both directions). Figured glass (dents).

The new Ripple tool.  All distort tools use resampling for improved image quality, and all provide real-time previews.
The new Ripple tool. All distort tools use resampling for improved image quality, and all provide real-time previews.
The new Figured Glass tool uses Perlin Noise to provide a warped glass look to images.
The new Figured Glass tool uses Perlin Noise to provide a warped glass look to images. (Note: the source image is a promotional photo for ABC’s Once Upon a Time.)

Vastly improved file format support

The new JPEG export dialog.  Optimization is a lossless way to reduce file size - very handy for JPEGs headed to the web.
The new JPEG export dialog. Optimization is a lossless way to reduce file size – very handy for JPEGs headed to the web.

JPEGs now support automatic EXIF rotation on import, and a variety of options on export (Huffman table optimization, progressive scan, thumbnail embedding, specific subsampling). TIFFs support CMYK encoding and a number of compression schemes (none, PackBits, LZW, CCITT 3 and 4, zLib, and more). PNG exporting supports variable compression strength, interlacing, and background color chunk preservation. PPMs can be exported with RAW or ASCII encoding. BMP and TGA files now support RLE encoding. And for icons, animated GIFs, and multipage TIFFs, all images inside a file can now be loaded (instead of just the first one).

These format settings can be accessed from the Tools -> Options menu, and the new Batch Process tool also provides direct access.

Revamped standard tools, including Box Blur, Gaussian Blur, Smart Blur, and Unsharp Masking.

Smart blur can be used to smooth out specific features, like skin, while leaving edges and fine details intact.  (Image of the lovely and talented Rashida Jones, via Glamour)
Smart blur can be used to smooth out specific features, like skin, while leaving edges and fine details intact. (Image of the lovely and talented Rashida Jones, via Glamour)

PhotoDemon is now a much better photo editor, thanks to the revamp of its core convolution filters. Larger tool dialogs make it easier to see the result of your actions. Better performance means real-time previews, even at enormous radii (up to 200px for all filters, plus 500px for box blur!). And all convolution algorithms now use specialized edge handling code to make sure every part of the image – from center to border – is handled correctly.

Also, the program’s Gaussian Blur is now a true gaussian blur. There are no shortcuts, no estimations, and it’s still fast enough to preview in real-time.

New advanced color tools, including Shadow/Midtone/Highlight adjustments, color balancing, and monochrome-to-grayscale recovery

Shadow / Midtone / Highlight correction allows for detailed recovery of light and dark parts of an image.  Thanks to deviantart user deviantsnark for the sample image.
Shadow / Midtone / Highlight correction allows for detailed recovery of light and dark sections of an image. Thanks to dA user deviantsnark for the Borderlands wallpaper.
Color balance provides a per-color way to adjust the hue of an image (versus hue / saturation adjustments, which apply equally to all colors).  Thanks to dA user LadyGT for the beautiful artwork.
Color balance provides a per-color way to adjust the hue of an image (versus hue / saturation adjustments, which apply equally to all colors). Thanks to dA user LadyGT for the beautiful Tomb Raider artwork.

New stylize tools, including Film Grain, Vignetting, Modern Art, Trace Contour, Film Noir, and Comic Book

Vignetting refers to the rounded halo around the edges of the image.  The new tool allows you to add halos of any size, softness (how blurry the edges are), transparency, and color, and it can automatically fit the effect to any aspect ratio.  Thanks to dA user chrismickens for the great Mad Men artwork.
Vignetting refers to the rounded halo around the edges of the image. The new tool allows you to add halos of any size, softness (how blurry the edges are), transparency, and color, and it can automatically fit the effect to any aspect ratio. Thanks to dA user chrismickens for the great Mad Men artwork.
PhotoDemon now allows you to add artificial film grain to any image.  This effect was famously used in the Mass Effect trilogy of games to create a more gritty, realistic look.
PhotoDemon now allows you to add artificial film grain to any image. This effect was famously used in the Mass Effect trilogy to create a more gritty, realistic look.
Contour tracing uses a stack of unique algorithms to "paint" the edges of an image.  It is also a useful edge detection tool.
Contour tracing uses a unique stack of algorithms to “paint” the main features of an image. It is also a useful edge detection tool.

Noise removal via Median Filtering

Median filtering serves two main purposes: removal of image noise (unwanted pixel variance), and recovery of damaged images.  The severely damaged image above is courtesy Wikipedia; the after image is pure PhotoDemon (note that it recovers better than the Wikipedia example!).
Median filtering serves two main purposes: removal of image noise (unwanted pixel variance), and recovery of damaged images. The severely damaged image above is courtesy Wikipedia; the after image is PhotoDemon’s correction (note that it recovers more than the Wikipedia example!)

Automatic image cropping

If an image has empty space around the edges - like this Firefox wallpaper - Autocrop can automatically crop it for you.  The feature supports thresholding, so it works equally well on lossy formats like JPEG.
If an image has empty space around the edges – like this Firefox wallpaper – Autocrop can automatically remove it for you. Autocrop supports thresholding, so it works just fine on JPEGs.

New Batch Process Wizard

If I had to pick a personal “favorite” new feature in this release, it would be the brand-new batch processing wizard. This tool is a highlight of PhotoDemon’s emphasis on usability, and I researched more than a dozen other image batch processing tools while building it. I could be biased, but I believe PhotoDemon is now the best general-purpose image batch processor available on the web.

The first page of the new Batch Process wizard.  This step is by far the most intricate, and a ton of work went into exposing full functionality without overwhelming the user.  To my knowledge, PhotoDemon is the only batch processor that allows you to create your own batch list from any number of source directories spread across any number of drives.
The first page of the new Batch Process wizard. This step is by far the most intricate, and a ton of work went into exposing full functionality without overwhelming the user. To my knowledge, PhotoDemon is the only batch processor that allows you to create your own batch list from any number of source directories spread across any number of drives.

Drag-and-drop is now supported when building the list of images to be processed – not only from within the dialog, by dragging between list boxes, but also from Windows Explorer. Live previews make it much easier to find the images you want, while helpful instructions on the left-hand side expose some of the more nuanced functionality.

Once a list of images has been created, you can optionally choose to apply photo editing actions to each image.  Unlike other batch processors, PhotoDemon allows you to use any photo editing actions provided by the program.
Once a list of images has been created, you can optionally choose to apply photo editing actions to each image. Unlike other batch processors, PhotoDemon allows you to use any photo editing actions provided by the program – not just a tiny subset.

Page 2 is the barest page of the new wizard. The current version allows you to skip photo editing actions (if you want to just do a batch rename or format conversion, for example), or you can apply any recorded macro. In the next release, I will add a set of “one-click” presets for common actions, like resizing, or optimizing images for the web.

Once you've created a list of images and chosen any photo editing actions, an output image format can be set.  New to this version, PhotoDemon can retain original image formats - allowing you to apply actions to mixed PNG/JPEG collections, for example.  Alternatively, you can select a single output format, with access to the program's full range of detailed format settings.
Once you’ve created a list of images and chosen any photo editing actions, an output image format can be set. New to this version, PhotoDemon can retain original image formats – allowing you to apply actions to mixed PNG/JPEG collections, for example.

Page 3 asks you to choose an output format. If you want to retain original image formats, that’s cool too – PhotoDemon now supports this! Alternatively, you can select a single output format, with access to the program’s full range of detailed format settings. In the example above, you can see all the options available for JPEGs, including new support for optimization (lossless file size reduction), thumbnails, progressive encoding, and specific subsampling.

The last step of the wizard asks you to choose a location to save all the processed files.  If desired, a number of rename options are also available.
The last step of the wizard asks you to choose a location to save all the processed files. If desired, a number of rename options are also available.

The final page asks you to select an output folder where PhotoDemon can save the processed images. New to this release is a wide range of renaming options – things like adding custom text to each filename, removing text from each filename, changing case, and replacing spaces with underscores for web-bound images. Additionally, original filenames can be retained, or PhotoDemon can just use ascending numbers.

So that’s the new batch wizard! I’d love feedback from power users, as there are a lot of moving parts to the batch tool, and while I have been very thorough in my own testing, it’s impossible to test every combination of variables. So if you find anything that doesn’t work, please let me know.

Improved features: Gamma Correction, Dilate, Erode, Monochrome Conversion, Histogram and Printing

As is usual with each PhotoDemon update, a number of existing tools received redesigns or new features. Gamma correction now displays live gamma curves, and each color component (red, green, and blue) can be adjusted individually. Dilate and Erode use a new algorithm that’s significantly more optimized, meaning sizes up to 200px radius can be previewed in real-time. Monochrome conversion supports any two color (not just black and white), while the printing and histogram dialogs were completely overhauled to make them more user-friendly.

The new gamma correction dialog.  The old dialog forced users to correct only one channel at a time.  The new one allows for correcting all three, with a live preview of the new curves.  Thanks to dA user Kouken for the Persona fan art.
The new gamma correction dialog. The old dialog forced users to correct only one channel at a time. The new one allows for correcting all three, with a live preview of the new curves. Thanks to dA user Kouken for the Persona fan art.

Universal color depth support at import and export time

PhotoDemon can now write 1, 4, 8, 24, and 32bpp variations of every supported file format. By default, when saving images, color depth detection is completely automated – the program will count the number of colors in an image and automatically select the most appropriate color depth for the output file. Alternatively, you can set a preference to manually specify color depth at save time. This also works for grayscale images; for example, the JPEG encoder will now detect grayscale images and write out 8bpp JPEGs accordingly. Alpha thresholding is also available when saving 32bpp images to 8bpp (e.g. PNG to GIF).

When saving a 32bpp image with a complex alpha channel to a simple format like GIF, the program has to reduce the alpha channel to binary values.  A new threshold dialog helps you find the perfect value.
When saving a 32bpp image with a complex alpha channel to a simple format like GIF, the program has to reduce the alpha channel to binary values. A new threshold dialog helps you find the perfect value.

This feature was a nightmare to implement, as PhotoDemon supports a huge variety of file formats, and each one has a detailed list of color depths it does or does not support. Full support for transparency adds a whole other layer of complexity. But now that the feature is completely implemented and rigorously tested, I can’t imagine it any other way. Color depth is not something users should have to worry about, and automatic handling should be a feature of every photo editor (rather than pestering you for color depth every time you save… *cough* GIMP *cough*).

New feature: pngnq-s9 plugin for optimizing PNG files

At the request of a good friend, PhotoDemon now provides integrated support for the pngnq-s9 variety of the famous pngnq library. For the uninitiated, pngnq provides a way to reduce 32bpp PNG files to 8bpp while still preserving complex alpha channels, allowing for file size reductions of up to 75%. Pngnq provides superior results over other tools by using a neural network to reduce image colors, unlike the brute-force median cut algorithm used by software like pngquant. See here for a gallery of sample images if you’re curious.

Pngnq-s9 is a further improvement over stock pngnq, including cool features like YUV color space matching for better results, and the ability to preserve alpha values of 0 and 255. When saving 32bpp PNG files to 8bpp, PhotoDemon will now lean on pngnq-s9 to do the heavy lifting.

In the next version of PhotoDemon, pngnq-s9 support will be integrated into the batch process wizard as a new “optimize for web” option. For now, if you want to test out the feature, head to Tools -> Options -> Saving, and change the “set outgoing color depth” option to “ask me what color depth I want to use”. Then save a 32bpp PNG image to 8bpp and compare the file size.

New plugin manager and plugin downloader

Sometimes it makes sense for PhotoDemon to use an existing open-source project instead of me writing a new feature from scratch. These support libraries are included as “plugins”, and there are four of them in current version. Each one provides indispensable features (like scanner support) at a fraction of the cost involved to write such a feature from scratch.

Some of these plugins expose additional functionality, but it has always been a challenge for PhotoDemon to expose these additional features to the user. So the program now has a detailed plugin manager, where advanced users can change settings on a per-plugin basis, including activating or deactivating plugins as necessary. The manager also tracks availability and version numbers of each plugin.

It is now much, much easier for the program to keep its plugins up-to-date.  Advanced users may also find it useful to enable or disable plugins while testing various features.  All changes happen in real-time - no restart required.
It is now much, much easier for the program to keep its plugins up-to-date. Advanced users may also find it useful to enable or disable plugins while testing various features. All changes happen in real-time – no restart required.
The pngnq-s9 page of the plugin manager.  Advanced or esoteric plugin features can be adjusted here, which keeps the program's main preferences dialog uncluttered.
The pngnq-s9 page of the plugin manager. Advanced or esoteric plugin features can be adjusted here, which helps keep the main “Options” dialog uncluttered.

Many canvas and interface improvements

Larger effect and tool previews. Persistent zoom-in/zoom-out buttons. Image URLs and files can now be directly pasted as new images. Improved drag/drop support, including drag/drop from common dialogs. New “Safe” save behavior to avoid overwriting original files. New Close All Images menu. New algorithms for auto-zoom when images are loaded, meaning much better results at all screen sizes. Tool and file panels can now be hidden. Higher-quality dynamic icons for the program, taskbar, child windows, and Recent Images list. Improved support for low screen resolutions.

Program-wide performance improvements

More aggressive memory management means lower resource usage. Program loading has been heavily streamlined, and now happens in less than a second on modern hardware. Image loading is much faster and more robust, including better support for damaged or incomplete image files.

More robust and comprehensive error handling

When loading multiple images, the program will now suppress warnings and failures (such as invalid files) until all images have been loaded. Many subclassing issues have been resolved – so no more surprise crashes! Overall this release should be extremely stable.

Many miscellaneous bug fixes and improvements

This article is already way too long, so I won’t bore you with a list of all the minor fixes and improvements. For a full list, see the commit log at https://github.com/tannerhelland/PhotoDemon/commits/master

In Conclusion…

This release was a lot bigger than I’d like future releases to be. The biggest delay came from adding language support, as that affected every piece of text in every part of the program (nearly 10,000 words in total!). Now that language support is complete, I foresee future releases being much tidier and quicker.

A developer’s work is never done, and a roadmap for version 5.6 is already being worked on. Some features that didn’t make the cut for 5.4 – like improvements to the selection tool, or a “smart resize” option – were cut at the last minute, and they will be among the first features added to 5.6. The batch process wizard will see a number of additions, and I’d love to add some advanced multilanguage features, like a way for casual users to fix or adjust translations on-the-fly. I also think I’m finally ready to tackle the monumental task of writing a user manual… should be fun!

As always, the best way to stay abreast of PhotoDemon development is the official code repository at https://github.com/tannerhelland/PhotoDemon

But for now, I hope you enjoy all the new features in 5.4, and please remember to donate if you find the software useful.

PhotoDemon 5.4 Beta Now Available

  1. Summary
  2. Download
  3. List of what’s new and improved
  4. Known bugs

Summary

PhotoDemon 5.4 is nearing completion, and I need help testing it. Version 5.4 provides a bunch of new features, including French, German, and Dutch (Flemish) language support. If you can help translate PhotoDemon into another language, please let me know! The translation process is very simple, and it requires no programming experience or special software.

Version 5.4 also includes nine new distort tools, tons of new file format features including specialized PNG and JPEG optimization, improved memory management, a new plugin manager, real-time Gaussian, Smart, and Box blur tools with variable radius, a full Unsharp Mask tool, vignetting, median filtering, adding film grain, automatic cropping, contour tracing, a new Batch Wizard, redesigned tool interfaces, and more. Please download the beta and let me know if you find any bugs.

Download

The PhotoDemon 5.4 beta comes in two flavors:

Remember – if you are an advanced user, you can always download the most recent development build of PhotoDemon’s source code from its GitHub page.

PhotoDemon is funded by donations from users like you.
Please consider a small donation to fund development and to help me support my family.
Even $1.00 helps. Thank you!

List of what’s new and improved in v5.4 (so far)

  • Official support for multiple languages. This is the biggest addition in version 5.4, and I can only claim partial credit for it. Primary credit goes to Frank Donckers, a fellow VB programmer and the one who prototyped the initial translation engine. Frank also supplied the translations for French, German, and Dutch (Flemish), so I owe him an enormous debt of gratitude.
  • Vastly improved file format support. JPEGs now support automatic EXIF rotation on import, and a variety of options on export (Huffman table optimization, progressive scan, thumbnail embedding, specific subsampling). TIFF exporting supports CMYK encoding and a number of compression schemes (none, PackBits, LZW, CCITT 3 and 4, zLib, and more). PNG exporting supports variable compression strength, interlacing, and background color chunk. PPM exporting supports RAW or ASCII encoding. BMP and TGA now support RLE encoding. For ICO files, all icons inside the file can now be loaded (instead of just the first one).
  • Nine new Distort-style tools. Add and remove lens distortion. Swirl. Ripple. Pinch and whirl. Waves. Kaleidoscope. Polar conversion (both directions). Figured glass (dents).
  • New and improved standard tools, including Box Blur, Gaussian Blur, Smart Blur, and Unsharp Masking. Each of these functions now supports variable radii (up to hundreds of pixels), and all have been heavily optimized. Gaussian Blur is the fastest VB-only true gaussian ever written. (Not a joke.)
  • Tons of new tools, including Film Grain, Color Balance, Vignetting, Autocrop, Median, Modern Art, Trace Contour, Shadow/Midtone/Highlight, Monochrome -> Grayscale conversion, Film Noir, and Comic Book. All tools include real-time previews. A number of existing tools received big updates as well – particularly Gamma Correction, Dilate, Erode, Monochrome Conversion, and Printing.
  • New Batch Process wizard. This replaces the old Batch Convert tool, which was an interface nightmare. The new tool supports a number of new features, including drag/drop support of batch lists, live image previews, and tons of file renaming options (prefix, suffix, case conversion, removing text, conversion of spaces to underscores for web).
  • Universal color depth support at import and export time. PhotoDemon can now write 1, 4, 8, 24, and 32bpp variations of every supported file format. Color depth detection is automatic at save time – the program will count the number of colors in an image and automatically save to the most appropriate color depth. Alternatively, you can set a preference to manually specify color depth at save time. This also works for grayscale images; for example, the JPEG encoder will now detect grayscale images and write out 8bpp JPEGs accordingly. Alpha thresholding is also available when saving 32bpp images to 8bpp (e.g. PNG to GIF).
  • New pngnq-s9 plugin for optimizing PNG files. Pngnq-s9 is an optimized and feature-rich variant of the original pngnq optimization library. Pngnq-s9 works by converting 32bpp PNG files to 8bpp with a heavily optimized palette, including support for variable alpha channels. File size savings of over 50% are common. See the Options -> Plugin Manager -> pngnq-s9 menu for a full list of tunable parameters.
  • New plugin manager and plugin downloader. Plugins can now be individually enabled/disabled, and missing plugins can be automatically downloaded. All plugin installation and activation/deactivation can be applied without a program restart.
  • Many canvas and interface improvements. Larger effect and tool previews. Persistent zoom-in/zoom-out buttons. Image URLs and files can now be directly pasted as new images. Improved drag/drop support, including drag/drop from common dialogs. New “Safe” save behavior to avoid overwriting original files. New Close All Images menu. New algorithms for auto-zoom when images are loaded, meaning much better results at all screen sizes. Tool and file panels can now be hidden. Higher-quality dynamic icons for the program, taskbar, child windows, and Recent Images list. Improved support for low screen resolutions.
  • Many performance improvements. More aggressive memory management means lower resource usage. Program loading has been heavily streamlined, and now happens in less than a second on modern hardware. Image loading is much faster and more robust, including better support for damaged or incomplete image files.
  • Much more robust and comprehensive error handling. When loading multiple images, the program will now suppress warnings and failures (such as invalid files) until all images have been loaded. Many subclassing issues have been resolved – so no more surprise crashes! Overall this release should be extremely stable.
  • Many miscellaneous bug fixes and improvements. For a full list, see the commit log at https://github.com/tannerhelland/PhotoDemon/commits/master

Known bugs

Here is a list of known bugs with the current beta. These bugs will be fixed before the final release.

  • When a new language is selected, some text may not be translated. This is not a problem with the translation engine – it is a problem with the translation files, which are still being finalized. All text will be translated in the final release.
  • When using a language other than English, some text may overflow its boundaries or disappear off the page. This is a known problem that is still being worked on. All text – in any language – should fit properly in the final release.