The Sandbox Post

Single Post Permalink

View Thread: HD Photo Command Line Encoder
  • User profile image

    I created a very basic command line encoder to convert images to the HD Photo format to do some basic tests. I did it because i don't have Photoshop so i can't use the new beta HD Photo plugin. Vista's new Photo Gallery is able to read these .wdp files but i don't think it's possible ti view on XP without someone whipping up a WPF image viewer or by using Photoshop so i recommend you use the Windows Photo Gallery app in Vista to view the output files.

    The app uses the new managed classes for Windows Imaging Component that are part of WPF (in the System.Windows.Media.Imaging namespace) so you'll need the .NET Framework 3.0 installed before you can use it. I included the full source code as well as a compiled EXE so feel free to mess around with the code.

    The code is commented a bit (mostly function explanations) but this was thrown together in a couple of hours (including reading through the docs) so don't expect any miracles. Error handling and input checking isvery basic as well so doing silly things and breaking the app isn't hard. I also do not support the advanced codec options, just the basic quality level.

    The app saves files into the same folder as the input file(s) with the same filename except they have a .wdp extensions (Vista still doesn't recognize the .hdp extension).

    The app should be runnable on XP but don't expect to be able to view the files on XP unless you have Photoshop and the HD Photo beta plugin installed.

    Here are some examples of the usage:
    HdpEncoder "C:\Users\Stebet\Pictures\test.png" -q 1.0 - Saves the picture as a lossless .wdp file.

    HdpEncoder "C:\Users\Stebet\Pictures\test.png" - Saves the picture using a quality setting of 0.9 (default).

    HdpEncoder "C:\Users\Stebet\Pictures\test.png" -q 0.5 - Saves the picture using a quality of 0.5. The Quality can range from 0.0 to 1.0 with 1.0 being lossles and 0.0 being horrid quality Tongue Out.

    HdpEncoder "C:\Users\Stebet\Pictures\SomePictureFolder" -q 0.8 - Saves all the images in a folder as .wdp's with a quality setting of 0.8

    HdpEncoder "C:\Users\Stebet\Pictures\test.png" -s 102400 - Saves the picture as a 100 kilobyte .wdp file using binary search to find the optimal quality for that file size, using a 2% file size error margin, brute force by encoding again and again and looking at the resulting file size. This is good if you want to compare .wdp to .jpg for quick comparison purposes. Do not though that it is not using any of the advanced codec options so the comparison isn't very accurate except for quick and dirty testing.

    As input you should be able to use .bmp, .jpg, .png, .gif, .tiff and .wdp at least (can't remember what other file formats are supported with the WIC by default).

    That's all for now, enjoy the code and feel free to mess around with it and experiment.