Monday, December 12, 2011

Slow e-mail on forum fixed

For the last couple of months, e-mails sent from the forum have taken many hours to arrive. This was particularly frustrating to new users who want to ask a question and have to wait until the next day for their verification e-mail to arrive, but it also delayed my ability to get notified that a new post needed attention.

Last week I was able to dig into this. Initially I suspected the web hosting company had an overloaded e-mail server, so I submitted a help desk ticket with them. They couldn’t find any issues on their end, so I started looking at the source code of the open source forum software YetAnotherForum.NET. Eventually I tracked down an issue with their code, which I was able to work around by clearing out one of the database tables that held e-mails waiting to get sent. I submitted an issue with their bug tracker, so hopefully they’ll be able to resolve it.

E-mails seem to be instantaneous again, so I think we are back in business. I offer my apologies for any inconvenience this has caused.

Wednesday, November 9, 2011

WPI version of Gallery Server Pro 2.6.0 released

Microsoft has completed their testing of 2.6.0 and published the new version to their web application gallery. A link to install it is on the download page.

Monday, October 31, 2011

Version 2.6 released

Gallery Server Pro 2.6 is now available. It sports a brand new file upload widget, the ability to encode video and audio files, and much improved SQL CE performance. Full details about this release are posted on the release history page.

To upgrade an existing version, just copy the files from the upgrade package over the ones in your existing web directory. If you are upgrading from 2.3 or from .NET 3.5 or earlier, there are a few extra steps – full details are in the Admin Guide. If you are using the DotNetNuke module, just follow the standard module install steps.

I covered the new features in my previous blog post, so here I’ll just cover what is missing from that post.

New file upload experience

The ComponentArt Upload control has been replaced with Plupload. There are several benefits:

  • HTML 5 drag and drop support
  • Ability to create a compressed version of images before uploading them
  • Takes advantage of advanced browser features while gracefully degrading when necessary
  • Progress feedback in medium trust scenarios
  • Multiple file selection

When the add objects page loads, the upload control detects your browser’s capabilities and chooses the most appropriate runtime, based in this order of preference: HTML5, Silverlight, Flash, BrowserPlus, and HTML4. The runtime is shown in a tooltip when you hover over the upload area, as seen in the screen shot below.

The exact features available depend on your browser’s capabilities, including whether it has Flash or Silverlight installed. For example, drag and drop works only in Chrome and Firefox. Client side image resizing requires Flash or Silverlight to work in IE.

Client side image resizing

To request that images be resized on the client before being uploaded, select the ‘Discard original file’ option below the file selection window, as seen here:


When that option is selected and the browser supports client-side resizing, a compressed copy of each image is created in the browser and then uploaded to the server. This can dramatically reduce the length of time it requires to upload files. If the browser can’t create a compressed file, the original is uploaded and the server takes care of creating the compressed version and discarding the original file, just like how it worked in previous versions of Gallery Server Pro.

In most cases, the image’s metadata is copied to the compressed version so that it can be extracted on the server. However, there is one unfortunate exception. The Silverlight implementation, which is often used in Internet Explorer, fails to copy the image’s metadata to the compressed file, resulting in the metadata being lost. There are two workarounds:

1. Do not select the ‘Discard original file’ option when uploading files. Instead, delete the original files after they have been uploaded with the ‘Delete original files’ option in the Actions menu.

2. Modify the file upload’s control definition so that it never uses the Silverlight implementation, or at least prefers the Flash one to the Silverlight one. Do this by opening the file gs\pages\task\addobjects.ascx in a text editor and looking for this line:

runtimes: 'html5,silverlight,flash,browserplus,html4',

Either delete Silverlight from the list or rearrange it to be after Flash. However, in my experience the Flash runtime is not as robust as the Silverlight one, so that is why I choose to prefer Silverlight.

Video / audio encoding

Version 2.6 adds support for encoding video and audio files to other formats after uploading. For example, you can upload an AVI file and have it automatically converted to a Flash Video file (FLV). The original AVI file is still available by clicking the view original button, much like original images are always a click away, even though web-friendly ones are shown by default.

The encoding is done by FFmpeg, a popular open source utility that Gallery Server Pro was already using to generate thumbnail images from videos. FFmpeg is included in the Gallery Server Pro Binary Pack. Note that your gallery must be running at full trust in order to execute FFmpeg.

You have complete control over which files are converted, to what they are converted, and how it is done. Here are the default encoder settings you’ll see when you look at the Video & Audio page in the site admin area:


These settings are interpreted as:

  • Do not encode MP3, MP4, FLV, or M4A files.
  • Try to convert all video to FLV. If that fails, try converting it to MP4.
  • Convert all audio to M4A.

Feel free to adjust these as needed. I experimented with several variations and settled on this as the best compromise. Originally, I preferred converting to MP4 H.264 first, using FLV only when that failed. But, while MP4 files have several advantages, such as being a (fairly) open standard, small files sizes, and the ability to play without a plug-in in some browsers, it has one big limitation: The MP4 files created by FFmpeg must be fully downloaded by the browser before they begin playing, so you might have to wait a while before your video starts. This is a limitation of FFmpeg, not MP4 H.264, so I am hopeful that a future version resolves this. For now, Gallery Server Pro will default to converting video to Flash Video.

Viewing the encoding progress

An encoding’s progress is monitored as it processes each file. You can see the latest information about an encoding by refreshing the web page and then clicking the Expand link in the encoding queue.

Adjusting the encoding timeout

During QA testing, I noticed that certain video files would hang, continuing to use processor resources but not making any progress. Worse, when this happened, the encoding process didn’t respond to requests to cancel it, unless you used Task Manager to kill it. This is a potentially nasty situation because encoding uses a lot of server resources, and you don’t want it running for hours hammering away on your server’s processor. Your hosting company could get quite upset.

The solution I came up with was to set a timeout when kicking off the encoding process. The timeout default to 15 minutes (900,000 milliseconds) and can be set in the site admin area as seen in the screen shot above. If the encoder is still running when the timeout fires, it is automatically cancelled.

You may need to increase this timeout if converting large files. Whenever a timeout is hit that causes an encoding to be abandoned, an entry will be written to the error log.

Rebuilding encoded files

Gallery Server Pro treats the encoded video and audio files just like it does the optimized images that are created for image files. The encoded versions are shown by default when you view the media object, but the original is available by clicking the ‘View original’ button in the toolbar.

To build encoded versions of your media objects after you upgrade to 2.6 or anytime you change an encoder setting, run a synchronization with the ‘Rebuild optimized versions’ option selected. The existing encoded version will be replaced by a freshly created one.

iOS support

The old handler that served media files didn’t support HTTP range requests, which is a technique some browsers use to request a portion of a media file. iOS devices require this support, so for version 2.6, the handler was rewritten to support these types of requests. Now any iOS supported file can be played in your device from the gallery. I believe the current supported file types are MP4, MP3, M4V, MOV, and M4A.

If you have media files in your gallery that are not supported in iOS, you can tweak the encoder settings to create an iOS-compatible version. One easy way to do this is to reposition the MP4 encoder setting to come before the FLV setting in the encoder settings section. Just remember the one big flaw with MP4 files – they must be fully downloaded in the browser before they begin playing.

Monday, October 10, 2011

Version 2.6 is faster and brings new uploader, iOS support, video/audio encoding, and more

You know, I wasn’t planning to release a version 2.6. Right after 2.5 was released a few months ago, I started cranking away on version 3, which is a significant release that adds all the top features you voted for in the poll. It was coming along great when something happened.

A fan of GSP came along and was willing to pay good money if I immediately added two features: (1) on-the-fly encoding of AVI videos to the web-friendly MP4 format, and (2) the ability to select multiple files in one step on the add objects page. So I added those features to the 2.5 codebase and gave it to the client as a custom build. These are features many of you would find useful, so I will soon be releasing version 2.6 to bring them – and a few bonus features - to you. Here is the complete list:

  • 15X faster SQL CE performance
  • New file upload experience
  • Client-side image resizing
  • iOS support
  • Improved browser caching
  • Video and audio encoding

The release is at least three weeks away, but hopefully not more than a couple months. I am putting the finishing touches on it now and will get it to you as soon as I can.

15X faster SQL CE performance

Version 2.5 added SQL CE as a data storage option while retiring SQLite. There were many benefits to SQL CE over SQLite, such as medium trust support, 32/64-bit support in a single package, and strong data typing and referential integrity. But, as many of you noticed, it was slower. One test I did showed that it took about eight seconds to load an album with 250 media objects, while SQL Server could do it in about 0.1 seconds. Although subsequent loads of the same album were almost instantaneous due to caching in the application, first impressions are important, and an eight-second page load is clearly unacceptable.

After profiling the application and database, I found that most of the page load time was spent retrieving the metadata for each media object, one SQL statement at a time. For example, a page with 250 media objects would make 251 calls to the database (one request to the media objects table and 250 to the metadata table). SQL Server does the same thing, but since it does it with a stored procedure whose SQL is compiled and cached, it is very fast. The SQL CE implementation uses Entity Framework 4.1 Code First, which does not cache the query plan (although I hear that is coming).

The solution was to modify the query logic to return the media objects and the metadata in a single SQL call. Instead of 251 trips to the database, it is now one. This change reduced the load time from eight seconds to 0.5 seconds, a 15x improvement. While that is much better, it is *still* about five times slower than SQL Server. For most users, though, it is quite acceptable. If you want the fastest performance and don’t mind the additional responsibilities that come with installing and managing SQL Server, than use SQL Server (even SQL Server Express, which is free, is faster than SQL CE). The rest of you can enjoy 15x faster SQL CE performance.

New file upload experience

Providing a great file upload experience has been challenging for web developers since the dawn of time. The first version of GSP used a nice open source component called NeatUpload. When ComponentArt added an upload component to its suite of controls in 2008, I moved to that one. Both, however, have annoying limitations: (1) You can choose only one file at a time (not exactly true with NeatUpload, but it required a Flash dependency), (2) They require the app to run in full trust.

When I was asked to support multi-file selection for a client, I knew I had to replace the ComponentArt control with something else. Like manna from heaven, I found a wonderful open source component called Plupload, which offers a dream list of features: HTML5 support (like drag and drop!), graceful degradation, support for medium trust, multi-file selection, and more. For example, here is what the add objects page looks like after I drag four image files from Window Explorer onto the page:


While uploading the files, the vast majority of users will see a nice progress bar indicating the status of the upload, even when the app is running in medium trust. The only ones who won’t are those running an old browser without Flash, Silverlight, Google Gears, or BrowserPlus. Not even your grandmother should fit into that category.


The real beauty of this upload control is that it takes advantage of advanced browser capabilities while gracefully degrading when necessary. So, enjoy drag and drop if you’re using Chrome or Firefox, but IE6 users can still upload files using a file selection dialog.

Client-side image resizing

I saved my favorite Plupload feature for its own section - client-side image resizing. Rather than waiting for a hundred 5 MB digital camera photos to crawl their way to the server, you can let the browser create smaller, web-friendly versions for you, resulting in images that upload in a fraction of the time. Now you’re done in seconds instead of minutes (or even hours).

I’ve been wanting to add this feature for a while now, and even went so far as to ask a friend of mine earlier this year to build a prototype using Silverlight and fjcore. But now we get this feature for free, and without any dependencies on plug-ins. Sweet!

The one downside - this feature requires Firefox or Chrome. But as more browsers become HTML5 compliant, expect support to grow.

iOS support

The current version of GSP won’t play video or audio on iOS devices (iPhone, iPod, iPad), even when specifying a supported file type like MP4 and using the HTML 5 video and audio tags. This was because iOS requires HTTP range support, and GSP’s HTTP handler didn’t support that. For 2.6, the handler has been re-written from the ground up to support HTTP range requests.

GSP 2.6 will support any media file in iOS that is natively supported. Currently, that means MP4, MP3, M4V, quicktime, and M4A.

Improved browser caching

Rewriting the HTTP handler provided an opportunity to take another look at how media files are cached in the browser. The 2.5 handler sends HTTP header values to the browser that instruct it to cache the images for thirty days. But in my experience some browsers seem to ignore this advice and request the images from the server anyway, except for after an image rotation, in which case the browser stubbornly likes to show the original, unrotated image, even after the user hits the refresh button or F5. I say that slightly tongue in cheek, but the basic idea is that there was an opportunity to improve the caching.

Here is an example set of response headers for an image in 2.4.8:


The same image in 2.6:


In 2.6, we got rid of the Expires setting and instead use Last-Modified and the Etag. By doing this, the browser will automatically be notified of rotated images and other changes to the media file. Even this isn’t perfect, though, as some browsers don’t check with the server when a user very recently loaded an image. But even in this case a click of the refresh button will force the browser to send the Last-Modified header, which will then cause the updated image to load.

Another change is that the file name is sent in the Content-Disposition tag. This is nice when you right-click an image to save to your hard drive. The value here will be used for the default filename, which is an improvement over getmediaobject.ashx, which is the default filename users saw in 2.5 and earlier versions.

Video/audio encoding

Version 2.6 adds support for encoding video and audio files to other formats after uploading. For example, you can upload an AVI file and have it automatically converted to an HTML5-friendly MP4 video. The original AVI file is still available by clicking the view original button, much like original images are always a click away, even though web-friendly ones are shown by default.

The encoding is done by FFmpeg, a popular open source utility that Gallery Server Pro already uses to generate thumbnail images from videos. FFmpeg is included in the Gallery Server Pro Binary Pack. Note that your gallery must be running at full trust in order to execute FFmpeg.

You have complete control over which files are converted, to what they are converted, and how it is done. For example, look at the Encoder Settings section in this screen shot:


The order of the encoder settings is important – the first one that matches is the one that is used. If it fails for any reason, the next matching one will be used. So, the screen shot shows that the preferred conversion for AVI files is to convert them to MP4 using these command line arguments for FFmpeg:

-i "{SourceFilePath}" -y -vcodec libx264 -fpre "{BinPath}libx264-galleryserver.ffpreset" "{DestinationFilePath}

It basically says to apply H.264 encoding using the options in a file named libx264-galleryserver.ffpreset in the bin directory. The text in brackets {} are parameters that are replaced at runtime. You can use any FFmpeg option to give yourself complete control. I have not yet decided on the exact encoding settings and parameters to use as default values – the ones that ship will likely look different than what you see here.

Continuing with our example, if the AVI to MP4 conversion fails for any reason, the next matching rule instructs the encoder to try converting to FLV. In my experience, this conversion often succeeds when the MP4 conversion fails, so this is a good fallback setting. The “all video” and “all audio” rules are buckets that match on all files with a video or audio MIME type.

The screen shot also shows the encoder queue, which is a list of media files that are waiting to be processed, are being processed, or are completed. Encoding can take a while, so this will be useful to see how things are going and to investigate any encoding errors that occur. The text returned by FFmpeg is shown in the Result column, and it contains all the conversion details – and errors – related to the process. You can also delete completed items or cancel pending ones.

Monday, August 1, 2011

Patch updated for DotNetNuke 6 bug

DotNetNuke 6.0.0, released a couple weeks ago, contains significant UI updates and new features. Gallery Server Pro is fully compatible with this release except for one issue I fixed today. Clicking the Browse button on the Add objects page doesn’t show the file open dialog box. Instead, nothing happens. This occurs only for IE9 users in standards mode; in compatibility mode – and for other browsers – it works fine.

I had to dig into the ComponentArt source code to fix the javascript for the Upload control. ComponentArt had some IE-specific code for calculating the position of elements on the screen. IE9 changes how they are calculated, resulting in a broken browse button. The fix was easy enough – just an extra condition in one of the functions to alter behavior based on whether IE is in compatibility or standards mode.

I updated the patch to include the fixed ComponentArt.Web.UI.dll. Just copy it into your bin directory. Although my tests indicate the issue is only with the DotNetNuke version of Gallery Server Pro, you may find you need it for the stand-alone or WPI version if you have GSP integrated into an existing application. How can you tell if you need it? Well, try to upload a file with IE9. If it works, you don’t need it. Smile

Thursday, June 23, 2011

Gallery Server Pro Binary Pack Updated

The Gallery Server Pro Binary Pack adds additional functionality to your gallery, such as thumbnail extraction from videos, TXT, PDF, EPS, and PSD (Photoshop) files. The pack consists of three open source components – GhostScript, ImageMagick, and FFmpeg. They are free and easy to install. The only requirement is that your site must be running in full trust to take advantage of them.

Today I updated the pack to include the latest version of each utility (GhostScript 9.02, ImageMagick 6.70, FFmpeg 0.8). Download it here. To update your existing components, copy the contents of the bin directory in the download to your bin directory, then run the GhostScript setup program. I don’t know if you need to uninstall the previous version of GhostScript first – as a safety precaution you may want to.

Tips for upgrading to Gallery Server Pro 2.5

Since releasing 2.5.0 a couple weeks ago, I am pleased the upgrade is going smoothly for the vast majority of you. However, a few support issues seem to be repeating themselves, so I wanted to throw out some tips to help it go smoothly.

Back up before upgrading – Make a backup of your database and web files before the upgrade. That way, in case anything goes wrong, you have something to revert to.

.NET 4.0 required – Version 2.5 requires .NET 4.0, so be sure it is available. I recommend getting your 2.3 or 2.4 gallery running on .NET 4.0 before upgrading to 2.5. The Admin Guide has all the details – read it carefully.

SQLite to SQL CE migration errors – There have been two users who reported issues in the upgrade step that migrates data from the SQLite database to the SQL CE database. In one case, data in the Comment column of one of the aspnet_Users records had to be deleted before the upgrade would succeed (it was actually quite mysterious because the data didn’t *look* corrupt). In the other case, there were two records in the aspnet_Roles table that referred to an application that didn’t exist in the aspnet_Applications table. Since SQL CE enforces referential integrity – and SQLite does not – this caused the migration to fail. The fix was to delete the two records from SQLite and run the upgrade again.

In other words, you might have to clean up the SQLite data a bit to make it “fit” in SQL CE. If you have trouble, read the error message carefully for clues, then use a tool like SQLite Administrator to find and fix it. If you really, really get stuck, send it to me (roger*at*techinfosystems*dot*com) and I can take a look (make sure you provide details with as much info about the error as possible).

jQuery 1.6 or higher required – In early May, jQuery released 1.6, which broke backward compatibility with earlier versions. At the time, the workaround was to temporarily change your jQuery version to a pre-1.6 version. Gallery Server Pro 2.5 fixes the issues by using the new jQuery 1.6 prop() function (instead of attr()). Of course, this means 2.5 isn’t compatible with jQuery 1.5 and earlier. If you try to use jQuery 1.5 in GSP 2.5, the two main issues you’ll notice are broken next/previous media browsing and broken UI functionality in several of the site admin pages.

This means that after you upgrade your gallery, one of your first steps is to make sure you are referencing jQuery 1.6 or higher (on the site settings page). I recommend using the value “//”, which will use the most recent 1.* release available.

If for some reason you must use jQuery 1.5, you can revert to the old behavior by replacing all instances of “.prop(“ with “.attr(“. That needs to be done in these files: gs\pages\admin\gallerycontrolsettings.ascx, gs\pages\admin\metadata.ascx, gs\pages\admin\usersettings.ascx, gs\script\mediaobjectview.js, and gs\pages\admin\manageroles.ascx.cs. Note that the last file (manageroles.ascx.cs) is a code file and is only found in the source code version. Once you update it, you will need to compile it and deploy a new GalleryServerPro.Web.dll to your bin directory (the assembly is named TechInfoSystems.GalleryServerPro.dll in the DotNetNuke module).

DotNetNuke users – This jQuery gotcha is especially important for you, since most installations of DNN are using a pre-1.6 version of jQuery. Probably the easiest way to update your site to the latest version of jQuery is to select the “Use hosted jQuery version” checkbox in the Advanced Settings/jQuery section of the Host Settings page. This will automatically use the latest 1.* release of jQuery available, assuming the hosted jQuery URL settings is still at its default value of “//”.

SQL CE editor – With SQL CE 4 just being released, there really isn’t an excellent, simple, and free tool available to let you see and edit the data directly in the database. I expect that to change in the coming months as SQL CE picks up speed. For now, there are a few options, and I describe them in the Admin Guide. Look for the section Management Tools for SQLite, SQL CE and SQL Server.

Apply the patches – A patch is available that fixes a few bugs in the 2.5.0 release.

Be on the lookout for new errors when extracting metadata – Version 2.5 incorporates the WPF-based metadata extraction technique directly in the business layer, whereas earlier versions were invoked via reflection in a separate DLL (this provided enhanced metadata for users running .NET 3/3.5 while still working on servers running only .NET 2.0). The reflection-based technique had a side benefit in that all errors were wrapped in a special exception that GSP chose to ignore (after first logging it), preventing files with metadata corruption from causing any visible trouble.

Version 2.5 directly calls the metadata extraction code, so any errors that aren’t caught cause the file upload or synchronization to fail. Microsoft recommends against using global exception handlers to silently catch all errors, so what I need to do is add little catch blocks that catch each type of exception that may occur. However, I have no idea what those are until you tell me. That has happened twice a few times now, and I’ve updated the patch accordingly.

If you didn’t understand that techno-speak – what I am saying is this: If you get an error while syncing or uploading files, post a thread in the forum with all the details (look in GSP’s error log if necessary). I can’t fix what I don’t know about.

Deleted DLLs – One of the nice things about 2.5 is that it no longer needs several DLLs, so it deletes them during the upgrade:

  • AjaxControlToolkit.dll
  • System.Data.SQLite.DLL
  • Microsoft.Practices.EnterpriseLibrary.Caching.dll
  • Microsoft.Practices.EnterpriseLibrary.Common.dll
  • Microsoft.Practices.ObjectBuilder.dll
  • GalleryServerPro.Business.Wpf.dll
  • GalleryServerPro.Data.SQLite.dll
  • TechInfoSystems.TracingTools.dll

Obviously, if you are using GSP in a site that requires one or more of these assemblies, be sure to save a copy and then restore them when the upgrade is complete. I imagine the most likely DLL you need to preserve is AjaxControlToolkit.dll.

Note: The DNN upgrade won’t delete any DLL’s, so you don’t have to worry whether another module might need one of these assemblies.

Also, the ugprade wizard might find that it can’t delete one or more DLLs it wants to. In my experience, this is most likely System.Data.SQLite.DLL. If you discover this file still exists in your bin directory after the upgrade, you may delete it.

Tuesday, June 21, 2011

Patch For 2.5.0 Released

Edit: 2011-06-23 – added fixes for two new issues.
Edit: 2011-06-28 – added fixes for two more issues.
Edit: 2011-07-12 – added fixes for four more issues.
Edit: 2011-08-01 – added fix for one issue.
Edit: 2011-08-05 – added fix for one issue.

Today I released a patch for 2.5.0 to fix a few bugs that came to light after its release. The patch includes fixes for all three variants of Gallery Server Pro – the stand-alone version, the WPI version, and the DotNetNuke module.

To apply the patch, first make sure your site is running 2.5.0. Then download the patch and navigate to the folder that pertains to your flavor of GSP (stand-alone, WPI, or DNN). Copy the DLLs it contains to your bin directory. That is it – you do not have to restart IIS or go through an upgrade wizard.

Download the patch here. Here is what is fixed:

  • Viewing error log generates "String was not recognized as a valid DateTime" error – This may happen when the server has a non-US culture.
  • An ArgumentNullException may be thrown during an auto-sync – I believe this happens only when one or more of your images contain GPS data.
  • (DotNetNuke only) Error when anonymous browsing is disabled for a gallery and an anonymous user attempts to view it
  • (added June 23) Error "Property cannot be found" when adding or syncing an image
  • (added June 23) Error "Object must be initialized before operation can be performed" when adding or syncing an image
  • (added June 28) Error "Unexpected property type or value" when adding or syncing an image
  • (added June 28) ArgumentException or InvalidOperationException when adding or syncing an image
  • (added July 12) Error FileNotFoundException occurs during a synchronization
  • (added July 12) Error OverflowException when adding or syncing an image
  • (added July 12) User given incorrect confirmation message after rotating images
  • (added July 12) Wrong MIME type may be sent to browser for some media objects
  • (added August 1) Nothing happens when you click the Browse button on the Add objects page when using IE 9 in DotNetNuke 6.0.
  • (added August 5) A timeout error in FFmpeg interrupts synchronization

These fixes will be included in the next official release.

Friday, June 17, 2011

Fix for SQL Server users

Today I identified a bug in the SQL Server provider where it does not correctly handle roles that have been assigned to multiple albums. The package downloads have been updated, so if you downloaded 2.5.0 before today, grab the latest GalleryServerPro.Data.SqlServer.dll from the install or upgrade package and replace your version.

Tuesday, June 14, 2011

Gallery Server Pro 2.5 Released

Today I released Gallery Server Pro 2.5.0, featuring new support for Microsoft SQL Server Compact 4.0 (SQL CE), an improved upgrade experience, faster SQL Server performance, and numerous bug fixes. The compiled and source code versions are available for immediate download. The Web Platform Installer version has been submitted to Microsoft and should be approved within a few days. The DotNetNuke Module will be available in a few days as well.

Upgrading the gallery

The upgrade wizard has been revamped to make it even easier to upgrade your gallery. If you are currently using version 2.4 under .NET 4.0, all you have to do is copy the files from the upgrade package over your existing installation and then browse to the gallery. The upgrade wizard automatically appears and guides you through the process. If you are running an earlier version of .NET or are upgrading version 2.0 – 2.3, there are a couple more steps which are described in the Admin Guide.

The upgrade wizard automatically removes the cachingConfiguration section in web.config, which is no longer needed. (Caching is now done with the .NET 4.0 MemoryCache class.) It also deletes these DLLs from the bin directory:

  • AjaxControlToolkit.dll
  • System.Data.SQLite.DLL
  • Microsoft.Practices.EnterpriseLibrary.Caching.dll
  • Microsoft.Practices.EnterpriseLibrary.Common.dll
  • Microsoft.Practices.ObjectBuilder.dll
  • GalleryServerPro.Business.Wpf.dll
  • GalleryServerPro.Data.SQLite.dll
  • TechInfoSystems.TracingTools.dll

If you integrated the gallery into an existing site that requires one or more of these assemblies, be sure to save a copy and then restore them when the upgrade is complete. Similarly, if your site uses the caching functionality from the Microsoft Enterprise library, you will need to restore the cachingConfiguration section in web.config.

New SQL CE data provider

Earlier this year Microsoft released Microsoft SQL Server Compact 4.0. Prior to this release, it could not be used in ASP.NET applications. Microsoft spent a lot of effort making it work in a multi threaded environment like ASP.NET, and it now offers all of the benefits SQLite provided – such as XCOPY deployment and no external dependencies - while offering a few significant bonuses:

  • A single package for 32-bit and 64-bit operating systems – SQLite had a dependence on System.Data.SQLite.dll, which came in 32-bit and 64-bit flavors, necessitating a download package for each type of OS. While SQL CE also must be distributed with 32-bit and 64-bit versions of its engine, Microsoft figured out a way to have both of them deployed in the bin directory so we don’t have to worry about it.
  • Works in medium trust – SQLite only worked in full trust, forcing users in reduced trust environments to use SQL Server, which is more difficult to set up and maintain and not supported by some hosts. And when it is supported, it is often an extra cost option.
  • Increased data integrity – SQLite did not do type checking to verify, for example, that an integer is really being stored in the AlbumId column, nor did it enforce referential integrity. SQL CE does both.
  • Officially supported by Microsoft – SQLite has a robust user community, but the release of SQL CE pretty much eliminates any compelling reason to use SQLite. I expect that interest in maintaining the SQLite ADO.NET provider will shrivel up.

Gallery Server Pro uses Entity Framework 4.1 Code First and LINQ to communicate with the database. This technique allowed me to crank out the provider in a fraction of the time it took me to write all that ADO.NET code used in the SQLite and SQL Server providers.

One of the biggest benefits is that I was able to update the Web Platform installer version of Gallery Server Pro to use SQL CE instead of SQL Server. By switching to SQL CE, the installation process became much simpler because it no longer has to install SQL Server. I know a lot of users tried to install GSP through the gallery but got hung up with a SQL Server issue, usually something to do with logon credentials or not finding the database server. Those problems all disappear.

SQL Server is still fully supported. If you prefer to use it, be sure to download the install package instead of using the WPI.

Where is SQLite?

SQLite is no longer supported in 2.5 as I could not justify the effort in maintaining the provider. During the upgrade process, your SQLite data is imported to a SQL CE database file named GalleryServerPro_Data.sdf in the App_data directory. When the upgrade is complete, the old SQLite file at App_Data\galleryserverpro_data.sqlite is no longer used and can be deleted or archived.

If you were using SQL Server, you will continue to use SQL Server in 2.5.

.NET 4.0 requirement

Moving to SQL CE and EF Code First required changing the system requirements to .NET 4.0. This move brought a lot of side benefits:

  • Ability to use native .NET 4.0 caching instead of the Microsoft Enterprise Library, allowing us to get rid of the cachingConfiguration section in web.config and the three DLLs it required.
  • Use of LINQ. This simplifies certain kinds of coding patterns.
  • Elimination of multiple web.config files. Previous versions of GSP shipped with six – count ‘em – SIX versions of web.config for use in various .NET environments and trust levels.
  • Elimination of separate WPF assembly. I was able to integrate the WPF functionality – used for enhanced metadata extraction – into the business layer.
  • Reduced test matrix. Testing the code base on multiple .NET environments was time consuming.

Faster SQL Server performance

As I was refactoring the code to use the Entity Framework, I noticed opportunities for improving the performance of several areas. These improvements affected both data providers, but are especially noticeable when using SQL Server. The greatest improvements are in galleries having thousands of users or tens of thousands of media objects. This was achieved in three main ways:

  • Re-architecture of the maintenance algorithm that runs during each application restart.
  • Improving the algorithm that maps user roles to albums.
  • Using ordinal positions when retrieving data from a data reader. For example, using dr.GetInt32(0) instead of Int32.Parse(dr["AlbumID"].ToString(), CultureInfo.InvariantCulture).

jQuery 1.6 compatibility

When jQuery 1.6 was released on May 3, it introduced a breaking change that affected a few of the pages in the site admin area. At the time, I blogged about a workaround where you tell GSP to use the older version of jQuery. The new version of GSP fixes those issues, so after the upgrade you can point jQuery back to the original value “//”. Do this on the Site Settings – General page.

In fact, you have to do this, since the fix requires jQuery 1.6. Specifically, GSP uses the new prop() function. If you don’t point to the latest version of jQuery, you may discover problems in a few areas, such as the inability to navigate media objects using the Next and Previous buttons.

Code analysis

The code analysis feature of Visual Studio 2010 was used to implement coding best practices. I had run this a couple years ago but much of the code has changed and it was time to do it again. Nothing serious was found but I did make hundreds of changes. Most changes fell into these categories:

  • Perform parameter validation at function entry points and throw an ArgumentException and ArgumentNullException as appropriate.
  • Include an IFormatProvider when processing strings and numbers.
  • Ensure Dispose() is called on all disposable objects. I was already doing that on most but I had missed a few.

Elimination of Ajax Control Toolkit

GSP has used the Ajax Control Toolkit to provide a few impressive UI effects, such as fading when navigating between media objects and creating interactive HTML DOM elements. However, the industry has recognized that jQuery is a better option and has largely abandoned the toolkit. Furthermore, versioning issues have always been a hassle. GSP now uses jQuery for effects previously handled by the toolkit.

Fixed bugs (detailed report)

  • Watermark image is locked by IIS process
  • Watermarked image sometimes fails to be rendered
  • Thumbnail image not generated for PDF files
  • Paging doesn't work on search results page
  • Deleting the root album results in "Album not found" message
  • Incompatibility with jQuery 1.6.0
  • Blank page may appear when error occurs
  • (SQL Server) Delete unnecessary foreign key from gs_Album table
  • (Sql Server) Length of MIME type columns different between gs_BrowserTemplate
    and gs_MimeType
  • (DotNetNuke) Album treeview navigation doesn't work when user-friendly URLs are

Upgrading your gallery to .NET 4.0

Gallery Server Pro 2.0 – 2.4 runs on any version of .NET from 2.0 - 4.0. Beginning with version 2.5, Gallery Server Pro requires .NET 4.0 or higher. This change allows GSP to take advantage of new features such as Entity Framework Code First development for SQL Compact CE and LINQ, while also simplifying the packaging and documentation requirements. (You may have noticed that 2.4 ships with six versions of web.config!)

If you are currently running GSP 2.3.* or 2.4.*, I recommend upgrading your gallery to .NET 4.0 *before* upgrading the gallery code to GSP 2.5. Technically, you could perform the .NET 4 upgrade and the GSP 2.5 upgrade at the same time, but why complicate things? By separating it into two steps, if anything goes wrong, it will be easier to troubleshoot.

What if you are using GSP 2.0 – 2.2? Those versions never shipped with a .NET 4.0 version of web.config, and I don’t think it is worth the trouble trying to get them working under .NET 4.0 only to immediately upgrade to GSP 2.5. For these versions, I recommend performing the upgrade to .NET 4.0 and GSP 2.5 at the same time. The Admin Guide has instructions for how to do this.

The rest of this post is intended to help you get your GSP 2.3 – 2.4 gallery running under .NET 4.0. This basically involves two steps:

1. Configure IIS to run the application under .NET 4.
2. Update web.config to conform to .NET 4.

Configure IIS to run the application under .NET 4.

This step is performed with IIS Manager (type inetmgr in a Start-Run box). For IIS 6, right click the gallery web application and choose Properties. Then click the ASP.NET tab and select 4.0 in the ASP.NET version dropdown box.

For IIS 7 and higher, the .NET version is associated with the application pool the application is running under. In IIS Manager, select the Application Pools node in the treeview, then double-click the relevant application pool in the grid. A dialog appears where you can change the .NET Framework version to 4.0. If you don't know which app pool the gallery is running under, right-click the name of the application in the treeview and select Manage Application - Advanced Settings. This brings up a dialog window that shows the app pool.

If you are using a hosting provider, look in your host’s control panel for this setting.

Update web.config to conform to .NET 4.

The web.config file, stored in the root of the web application, contains several references to a specific version of .NET. These must be updated to .NET 4.0 references or, in some cases, removed since they are now present in the machine-wide web.config file. Follow these steps:

  1. Rename your existing web.config to web_old.config.
  2. Grab the relevant web.config from this download and copy to your web application. For example, if you have version 2.3 with SQLite as your database, use web.config from the “Files for upgrading from 2.3\SQLite” directory.
  3. (SQL Server only) Update the connection string to your SQL Server database in web.config with the one from your previous one (now named web_old.config). It should be named SqlServerDbConnection.


  • If you made any changes to your web.config file, you must manually migrate them to the new web.config file.
  • If your version is 2.3.3421 to 2.3.3512, you should also migrate the <location path="gs/services/Gallery.asmx"> section from your old web.config file. (This section is not required in 2.3.3512 and later, as there is a web.config file in the services directory that performs this task.)
  • You are on your own if you want to get GSP 2.0 – 2.2 working on .NET 4.0. It can be done, but you have to carefully upgrade your web.config to the .NET 4.0 version. As I said before, for these versions I recommend upgrading to .NET 4.0 and GSP 2.5 in a single step. Instructions are provided in the Admin Guide.

Tuesday, May 24, 2011

Bug: Thumbnail image not generated for PDF files

Today I discovered a bug that affects all galleries upgraded from a version earlier than 2.4.3. You are affected if all of the following are true:

  • You have PDF files in your gallery.
  • You originally installed GSP before version 2.4.3 and then upgraded to one of the later versions.
  • Your site is running in Full Trust.
  • You installed the Gallery Server Pro Binary Pack.

In short, this is a bug in the SQL upgrade script that shipped in 2.4.3 and later. Fortunately, there is an easy fix.

First, some background: In a default installation GSP creates a generic thumbnail image for PDF files, like this:


When you install the Gallery Server Pro Binary Pack, GSP uses the ImageMagick and GhostScript utilities to generate a thumbnail image that is an actual preview of the PDF file:


Today I discovered a bug, introduced in 2.4.3, where PDF files *always* get the generic thumbnail image, even when the binary pack is installed. The cause of this is a typo in the SQL upgrade script for 2.4.3:

UPDATE [gs_GallerySetting]
SET [SettingValue] = 'pdf,.txt,.eps,.psd,.tif,.tiff'
WHERE [SettingName] = 'ImageMagickFileTypes';

See the typo? I missed the period in front of ‘pdf’. To fix your gallery, update the setting to include the period. You can use this SQL:

UPDATE [gs_GallerySetting]
SET [SettingValue] = '.pdf,.txt,.eps,.psd,.tif,.tiff'
WHERE [SettingName] = 'ImageMagickFileTypes';

Since these settings are cached, recycle the IIS application pool to force the gallery to get a fresh copy from the database.

The next version of GSP will include a fix for this.

Tuesday, May 10, 2011

jQuery 1.6 introduces breaking change

On May 3, jQuery introduced a new version that breaks some of the functionality of Gallery Server Pro 2.4.6 and higher. Earlier versions are not affected. Also not affected is the Gallery Server Pro DotNetNuke Module, *unless* you explicitly changed the default jQuery settings. The good news is there is an easy fix I describe at the end of this post.


Gallery Server Pro uses jQuery to provide a rich user experience. Starting with 2.3.3750, a default installation of GSP uses the Google hosted versions of the jQuery library rather than a locally stored copy of the .js file. This allows the browser to use a previously cached copy of jquery, resulting in a faster loading page.

There are a number of ways one can construct the URL to point to Google’s copy of jQuery. Here are a few examples of how I’ve tinkered with the URL:




2.4.6 – 2.4.8: //

Notice how the version number is specified. By omitting the minor version from the 2.4.6 and later releases, Google automatically serves the latest 1.X release. You get the benefit of having the latest version of jQuery without having to explicitly upgrade.

But there is some risk with that approach, which brings me to the topic of this post. On May 3, jQuery released version 1.6. It contains a number of improvements and performance enhancements. Unfortunately, it also introduces a breaking change that causes an immediate problem on all 2.4.6 and higher Gallery Server Pro releases. Earlier GSP versions are not affected because the jQuery URL pointed to either a local jQuery file (versions earlier than 2.3.3750) or one of the 1.4 versions. jQuery 1.6 changes how attributes are handled. The details are in this blog post, but what it means to GSP is that the handling of checkboxes and the enabling/disabling of HTML elements in several of the admin pages are broken.

For example, as user happylynlyn pointed out yesterday in the forum, selecting the option ‘Override the following default settings’ on the Gallery Control Settings page no longer enables the child options. This issue also affects the Manage Roles, User Settings, and Metadata pages.

The issue only affects these few pages in the site admin area – browsing the gallery and performing tasks in the gallery (add/editing objects, etc) are not affected.

The Fix

I will have this resolved in the next release. Until then, there is an easy workaround – just tell Gallery Server Pro to use an earlier version of jQuery. On the Site Settings – General page, update the jQuery path to specify version 1.5:


Friday, April 29, 2011

Gallery Server Pro 2.4.8 Released

Version 2.4.8 was released today. It contains fixes for three bugs that won’t seriously affect most people, but I wanted to get it out the door so I can focus on the 2.5 drive. The release includes these fixes:

  • Logging in does not preserve the original requested album or media object
  • Cannot manage users or roles when they contain certain characters
  • (DotNetNuke) Gallery doesn't work when user-friendly URLs are disabled

Get more details about the bugs here. To upgrade from 2.4.7, download the 2.4.8 files to your hard drive. Then replace the GalleryServerPro.*.dll files in the bin directory with those from the download. Finally, replace the following files in your gallery with the matching file in the download:

  • App_GlobalResources/GalleryServerPro.resx
  • gs/pages/admin/usersettings.ascx

If you are upgrading from a version earlier than 2.4.7, follow the instructions in the Admin Guide.

Friday, April 22, 2011

Gallery Server Pro Roadmap

I’ve gotten a lot of good feedback in the poll about the future of Gallery Server Pro – keep on voting! I am particularly pleased that the two lowest vote-getters are “improve performance” and “improve reliability”. That tells me you think Gallery Server Pro is fast and robust. I spent a lot of time getting it there, so it is gratifying to see some objective confirmation.

Based on those results and my internal spidey sense, here is where I see the upcoming versions and features working out. This is rough and can and will change, but at this moment it is my best guess.

2.4.7 (Released April 21, 2011)

  • All known issues in the 2.4.X code base are fixed and the product is stable and performing well.

2.5 (June 2011)

  • Migrate the code base to .NET 4.0.
  • Replace the SQLite data provider with SQL Server CE 4.0. This will allow for simple xcopy deployment that works in medium trust – kind of the holy grail I’ve been wanting for several years.

3.0 (2012)

  • Easier skinning/customizing UI (the top vote-getter in the poll)
  • User comments/ratings (#2 in the poll)
  • New upload experience (#3 in the poll). Allow multiple file selection on client. Possibly include option to create optimized images on client and upload those rather than original images, greatly reducing upload time.
  • Tagging (heirarchical?)
  • Virtual albums: browse by tags, most recent, top rated, most commented, user
  • Editable metadata
  • New sorting options
  • Allow users to password protect individual albums/media objects
  • Namespaced javascript so multiple instances of control can be on same web page

Future (2012-2013)

  • Add viewmode 'Map' that displays map of GPS coordinates
  • Allow gallery-level settings to be overridden at the album level (MO title template, watermark, etc)
  • Allow separate media object title templates for thumbnail and optimized images
  • User quotas
  • Ability to regenerate captions from updated MO title template
  • Mobile app support
  • DeepZoom support
  • Fullscreen slideshow
  • Expand scope of error log to be an event log
  • E-mail notifications of gallery updates
  • Log history (viewing, edits, delete, etc)

Way, way Future (2040-2050)

  • Include teleport feature to take viewer to GPS location embedded in image

Keep your feedback coming. Does this roadmap gel with your needs?

And keep those donations coming! Your financial support allows me to continue working on Gallery Server Pro instead of taking some high-paying consulting work. The pay is poverty-level (average donation for Jan-Mar 2011 was $1300/month), but is highly satisfying, so I expect to keep at it as long as I can keep paying the bills.

Thursday, April 21, 2011

Gallery Server Pro 2.4.7 Released

Today I released version 2.4.7 of Gallery Server Pro. All versions have been updated, but the Web Application Gallery version takes a few days to get approved by Microsoft, so be patient for that one. There are no new features in this release; only bug fixes and one web.config change:

  • Various functions do not work when viewStateEncryptionMode="Always"
  • Case difference in username during logon causes duplicate user album
  • Username not HTML encoded
  • Exception data of inner exception not logged
  • Possible NullReferenceException when gallery contains images with GPS metadata
  • HTML embed code contains incorrect URL when the website is installed in a virtual directory
  • Role name that contains HTML cannot be assigned to user
  • Cannot add/remove roles for user when membership is read-only
  • embed.aspx moved from web root to \gs\ directory
  • web.config change: ViewStateEncryptionMode now set to “Always”

More details can be found in the Fixed Defect Report.

To upgrade from 2.4.6, download the 2.4.7 files to your hard drive. Then replace the GalleryServerPro.*.dll files in the bin directory with those from the download. Finally, replace the following files in your gallery with their matching file in the download:

  • App_GlobalResources/GalleryServerPro.resx
  • gs/embed.aspx (this is a new location; you may want to keep the original embed.aspx in the root directory if you have existing bits of embed code that point to this file)
  • gs/controls/myaccount.ascx
  • gs/controls/albumedittemplate.ascx
  • gs/controls/thumbnailview.ascx
  • gs/pages/admin/manageroles.ascx
  • gs/pages/admin/manageusers.ascx
  • gs/pages/myaccount.ascx
  • gs/script/mediaobjectview.js

If you are upgrading from a version earlier than 2.4.6, follow the instructions in the Admin Guide.

I’ll discuss a couple of the more interesting bugs.

Various functions do not work when viewStateEncryptionMode="Always"

I first learned about this issue from a user about a month ago. First, some background: One can specify that the view-state always be encrypted by setting a property in web.config:

<pages … viewStateEncryptionMode="Always">

When not specified, this setting is “Auto”, which means view-state is encrypted only when a control requests it. GSP works fine in “Auto” mode, but one of the third party controls it uses cannot handle the setting “Always”. This is the Callback control from ComponentArt, which is a nifty control I use for Ajax callbacks that is a nice balance between raw Ajax requests and the heavyweight UpdatePanel. When view-state is encrypted and the Callback control’s PostState property is set to “true”, this control fails with one of these messages:

“An error occurred while communicating with the server. Try again. Error: Invalid response from server.”

“The data could not be loaded.”

This issue affected the following functions in GSP:

  • Album thumbnail paging
  • Adding/editing a user on the Manage Users page
  • Adding/editing a role on the Manage Roles page

While this problem has always existed, it hasn’t appeared on my radar until a few weeks ago. This is because version 5.6.1 of DotNetNuke, released January 19, 2011, started using “Always” as its default setting. DotNetNuke didn’t announce the change ahead of time because they didn’t think it would be a breaking change for anyone. But this was a big problem for GSP.

I contacted ComponentArt and they were responsive in evaluating the issue, but in the end they couldn’t provide a fix, acceptable workaround, or estimated date for a fix. So I replaced the album thumbnail paging with a traditional hyperlink architecture, where navigating to the next and previous pages is done with hyperlinks. And I re-architected the user and role management pages to use Microsoft’s UpdatePanel. In the end the changes should be largely invisible to end users.

To keep the settings consistent between the various flavors of GSP, the web.config of all versions now set this setting to “Always”. There is a small performance impact of this change (about 1-2%), so if you don’t need this extra security and want the fastest possible gallery, feel free to change this back to “Auto”.

Cannot add/remove roles for user when membership is read-only

One of the great features of Gallery Server Pro is its ability to use Active Directory integration for membership. This can be easily achieved through a few simple edits to web.config (see the Admin Guide for step by step directions). However, there has always been a limitation where one can’t add or remove roles for a user when the web application doesn’t have permission to modify Active Directory data. The Admin Guide describes a few workarounds, but I finally got around to eliminating the limitation altogether.

When clicking the Save button for a user on the Manage Users page, the gallery does two things: (1) update the user properties in the membership provider (such as e-mail address, comment, or approval status), and (2) update the list of roles the member belongs to. Starting with 2.4.7, if there aren’t any changes to the user properties, then only the role membership is updated. That is, the gallery skips a call to the membership UpdateUser() method, thereby sidestepping the possibility of the membership provider throwing a permission error. Voila – you can now manage role membership for users even when using Active Directory in read-only mode.

Thursday, March 17, 2011

Better looking galleries in IE9

Gallery Server Pro makes extensive use of rounded corners and drop shadows to make a great looking gallery. While other browsers have supported these features for a while, IE has lagged behind. Now I am pleased to report that IE has finally caught up! After you upgrade to IE9 your galleries will suddenly look a little more awesome.

For example, here is a typical album as seen in IE8:


Now the same album in IE9:


The thumbnail images, the frame, and the paging controls all have nice rounded corners, and the images have a nice drop shadow effect.

When you click an image, this is what IE8 will show:


The same image in IE9:


Astute observers will notice that the IE8 screen shots *do* have a drop shadow similar to the IE9 shots. That is because years ago I decided I couldn’t wait for IE to add drop shadow support, so I implemented a complicated hack to simulate the effect with nested div tags and images. I describe the technique in this blog post. Gallery Server Pro still uses the older technique for IE 8 and earlier, but all other browsers – including IE9 – get the new CSS drop shadow. The end result is that using CSS instead of a hack results in much simpler HTML, allowing for such basic improvements as centering images. Here is an image in IE8 – notice how it is left-aligned:


The same image in IE9:


These are just a few of the places where better CSS support results in a better looking gallery. To get these improvements, all you need is IE9 and any version of Gallery Server Pro 2.4.0 or higher. Enjoy!

Thursday, March 10, 2011

Add the Facebook comment widget to your gallery

One of the frequent requests I get is the ability for users to comment on photos and other media objects. I am considering adding this feature – in fact, it is one of the items you can vote for in the poll I am running. But today I discovered a technique for incorporating the Facebook comment widget right into your gallery. I enabled this feature on an album in the demo site so you can see for yourself. Feel free to leave a comment on one or more photos – I’ll purge them periodically.

This is not for everyone. Users need a Facebook account, and it is a little tricky to set up and maintain. For these reasons, I am reluctant to add this as a built-in feature. But for some of you this will be an excellent addition to the gallery.

Here is what it looks like:


There are a few steps getting this to work.

1. Add a script tag to the web page hosting the gallery control.

Open default.aspx in a text editor and add this line somewhere in the <head> section:

<script src=""></script>

2. Update mediaobjectview.js

Two javascript functions in \gs\script\mediaobjectview.js must be updated to call the Facebook API. In showNextMediaObject() and showPrevMediaObject(), find this line of code: = "default";

Then add this line just *before* it:

if (typeof (FB) != 'undefined') FB.XFBML.parse();

Because the file is minified, it is difficult to edit, so for your convenience just grab the one used on the demo site. If you are running a different version than the one on the demo site you’ll have to manually edit the file. To make this easier, you could edit the un-minified version that is in the source code download (Website\gs\script\ and then run it through any minifier (like this one).

3. Enable HTML editing and add the ‘fb:comments’ tag.

Log in to your gallery as an administrator and turn on HTML editing on the User Settings page. Then add ‘fb:comments’ as a valid HTML tag.


4. Update each media object caption with the Facebook HTML snippet.

For each media object where you want to enable comments, edit the caption and add this HTML after the regular caption:

               <div id="fb-root"></div>
<fb:comments href=""></fb:comments>

Replace the URL with the actual URL to your media object. Notice there are several spaces before the first <div>. That is intentional, as it provides a buffer to prevent Gallery Server Pro from accidentally rendering the comment widget on the thumbnail image. Save your changes and then refresh the page. The Facebook comment widget should appear just below the caption.

Pretty cool, huh?

Updating the caption for every media object is pretty tedious, so below I describe a shortcut.

Disclaimers and caveats

BROKEN CAPTION EDITING – This technique breaks the ability to edit a caption on the single media object view. Once you comment-enable a media object, the only way to edit its caption is through the Edit Captions task available in the Actions menu. And when you do, you have to be careful not to edit the Facebook HTML that is part of the caption.

Remember, Gallery Server Pro was not designed for this comment widget, so it is kind of a hack to add it to the comment field. If you don’t like this limitation, then don’t use this technique.

NO SUPPORT – Gallery Server Pro does not provide support for the Facebook comment widget, so you are on your own. I did minimal testing and don’t know how robust it is or even whether it is a good idea. It may kill your hamster. That said, I am curious to hear your feedback and experiences.

Comment-enable your whole gallery (or just an album) in one step

Rather than update each media object one at a time, you can execute a SQL statement against the database to comment-enable all your media objects at once. Here is some example SQL – it adds the necessary Facebook HTML to any existing text in the Title column of the gs_MediaObject table.


UPDATE gs_MediaObject
SET Title=Title || "                <div id='fb-root'></div><fb:comments href='" || MediaObjectId || "'></fb:comments>"

SQL Server:

UPDATE gs_MediaObject
SET Title=Title + "                <div id='fb-root'></div><fb:comments href='" + MediaObjectId + "'></fb:comments>"

Add a WHERE clause – like in the second SQL – to update the items in just one album. It is beyond the scope of this post to tell you how to execute SQL, so if you don’t know, you’ll have to learn or just forget the idea.

As you add objects to your gallery, you will need to manually update each caption or re-apply the SQL. But don’t run the SQL more than once against the same set of media objects, or you’ll start to get multiple copies of the Facebook HTML.

More information

To learn more about the Facebook Comments Box, read the documentation. It includes information about moderation tools to help you manage the comments.

I think some of you will really like this trick. Let me know how it goes!

Wednesday, March 9, 2011

Vote for the features you want to see

Now that Gallery Server Pro 2.4 is good and solid I am thinking about the next major features for 2.5. What should they be? I have a hunch, but I want to be a bit more scientific about this, so I created an online poll. Vote for the features you want to see here:

There is a very good chance that the top two or three vote-getters will make into into 2.5, so make yourself heard! And if you want a feature that isn’t listed, want to add detail, or you want to remind me of a previous feature request that is important, add your comment to that thread.

Thursday, March 3, 2011

2.4.6 patched with minor bug fixes

Since releasing 2.4.6 on February 21, a few bugs have surfaced. I wanted to quickly fix them instead of making you wait for the next release, so I updated the existing 2.4.6 versions to include the fixes. These were updated today, so if you downloaded them earlier, you may want to upgrade.

These bugs were fixed:

  • BUG: ArgumentOutOfRangeException on account creation page when anonymous browsing is disabled
  • BUG: Auto-synch fails when images contain GPS data
  • BUG: (DotNetNuke only) Auto-sync function causes error emails to not be sent
  • BUG: “String was not recognized as a valid DateTime” error after enabling auto-sync in non-United States cultures
  • BUG: Cannot play audio or video when option 'Allow anonymous browsing of high resolution images' is disabled

There were also a few changes in behavior for the HTTP handler that serves media files to the browser:

  • A request for a resource that no longer exists now returns an HTTP 404 status code. Previously it returned 200 (OK) with an empty body. This change helps search bots know when to remove an item from its database.
  • File-not-found errors are no longer logged as an error. This is because search bots re-indexing a site can generate hundreds of file-not found errors by requesting items that had been moved or deleted since the last time. This shouldn’t be treated as an error.
  • A request that fails the security test now returns an HTTP 403 (forbidden) status code. Previously it return 200 (OK) but didn’t include the media file. This is basically a “best practice” change that shouldn’t have much impact.

The final change is that e-mails are no longer sent each time an auto-sync begins and ends. They are, however, logged to the error log – even though they are not errors. (Note to self: In a future version rework the error log to be an EVENT log.)


If your current version is earlier than 2.4.6, follow the standard upgrade instructions in the Admin Guide. If you are already on 2.4.6, just replace the following files in your bin directory with the ones from the 32-bit or 64-bit download (doesn’t matter, since these three are the same in both):

  • GalleryServerPro.Business.dll
  • GalleryServerPro.ErrorHandler.dll
  • GalleryServerPro.Web.dll

DotNetNuke Users – Download the latest ZIP module and install just as you would a new module. The installer will ask if you want to repair the current installation. Choose yes.

Monday, February 21, 2011

Gallery Server Pro 2.4.6 Released

Less than two months after 2.4.5 was released, I am pleased to announce 2.4.6. There are a bunch of new features along with the normal collection of bug fixes.

The Admin Guide has instructions for upgrading to this version. The short story is that you use the Upgrade Wizard for upgrading from 2.3.*. To upgrade from 2.4.*, simply replace the web files with the latest version.

The philosophy behind this release was to implement the “low-hanging fruit” features that have been frequently requested but didn’t require significant resources. In the coming weeks I will post a roadmap about what is coming down the pipe.

New features

  • Automatic synchronizations
  • Synchronizations can be remotely triggered
  • Synchronization performance increases, especially for large galleries
  • Improved UI feedback during synchronizations
  • Faster search performance
  • ‘Embed code’ allows media objects to be added to other web sites
  • New admin setting: Allow users to download media files but not entire albums
  • Albums always sorted at the beginning of any thumbnail list
  • Allow keeping underlying file or directory when deleting objects
  • More flexibility when choosing a thumbnail image for an album
  • More flexibility for generating captions for new media objects
  • More metadata extracted from files, including IPTC and GPS properties
  • GPS coordinates now link to Bing or Google Maps
  • Admin can specify order and visibility of metadata
  • jQuery path setting exposed in admin area
  • Additional application details shown in admin area
  • Improved thread safety
  • Added support for router port forwarding scenarios
  • Upgraded to jQuery 1.5
  • Upgrade to latest version of SharpZipLib

Bug fixes

  • Synchronization estimated time left never changes from “Calculating…”
  • Album thumbnails not always correctly updated after moving media objects
  • Null reference exception when HttpContext.Current.Request.Browser.Browsers is null
  • E-mail notification sometimes stops working
  • Anonymous user can view media object when anonymous browsing is disabled
  • Titles of new objects are empty strings when metadata value contains whitespace
  • Metadata window shows only the first 20 metadata items
  • DivideByZeroException caused by invalid metadata
  • Rating metadata imported when it has never been assigned
  • User loses breadcrumb location when saving change on Gallery Settings page
  • Gallery setting 'Discard the original image when it is added to the gallery' is always unchecked and cannot be enabled
  • Now able to extract ZIP archives created by Hotmail

Synchronization improvements

Several changes to the synchronization area improves user feedback, performance, and gives administrators additional management options.

Performance improvements: GSP has always been able to handle hundreds of thousands of files, but around the 100,000 object mark or so the synchronization process would get noticeably slower. Database profiling revealed that significant gains could be made by adjusting one of the stored procedures and adding an index and a few statistics. There were also some changes to the API that reduced unnecessary overhead. For example, there was no need to load the metadata associated with existing media objects at the beginning of a synchronization. By modifying the code to allow for a “lightweight” version of each media object, they load much faster and put reduced pressure on the memory of the server.

The database tuning applies only to SQL Server. If you are using SQLite and are experiencing performance issues, then you should migrate to SQL Server. The Admin Guide has instructions.

Improved UI feedback during synchronization: The first step in any synchronization is to load the existing media objects into memory. When the gallery contains hundreds of thousands of items, this can take a while. Prior versions of GSP did not update the progress window during this phase, leading users to wonder what was happening or thinking the application locked up. Worse, a bug compounded the problem by sometimes incorrectly showing “Calculating…” for the entire duration of the synchronization instead of giving meaningful updates.

The bug has been fixed. And now the progress window informs the user during the initial phase where items are loaded into memory, as seen here:


Auto-sync and remotely triggered syncs: You can now schedule a synchronization to automatically occur at periodic intervals. This allows the gallery to automatically stay up to date with files and directories in the media objects directory on the server. This feature can be managed on the Albums page in the site admin area:


The scheduling logic depends on the application being kept alive by periodic HTTP requests. If no one browses the gallery, the code that checks if a sync is required never runs. As you might expect, the sync interval is only approximate, but should be reasonably accurate in any gallery that has at least a few hits per hour.

One can also remotely trigger a sync through two new web services. These web services require a password – you choose that password in the admin page shown above.

How you invoke the web service depends on how it is configured in web.config. By default, it is set to accept HTTP POST.

Faster search performance

Search performance was improved by the addition of an index on the gs_MediaObject table. If you have hundreds of thousands of objects and are still experiencing slow searches, you can further improve performance by modifying the search stored procedure to ignore metadata in searches. It is named gs_SearchGallery. Use SQL Management Studio or a similar tool to delete or comment out the section that queries the gs_MediaObjectMetadata table.

This affected SQL Server only. Again, if you are experiencing performance issues with SQLite, it is time to migrate to SQL Server.

‘Embed code’ allows media objects to be added to other web sites

You can now get embed code for any media object by clicking one of the buttons above the media object:


This embed code lets you add media objects to other sites while keeping the original files on your own server.

New admin setting: Allow users to download media files but not entire albums

One of the cool features in GSP is that users can quickly download a bunch of media objects in a ZIP archive. However, there was a potential for a user to overwhelm a server by requesting that a top level album be packaged into a ZIP file. For example, downloading the root album in a gallery with 100,000 objects causes the server to try to add 100,000 files to a ZIP archive and then transmit it to the user. Not cool.

Starting in 2.4.6, an administrator can specify that only media objects in the current album can be added to a ZIP archive:


Albums always sorted at the beginning of any thumbnail list

Previous versions of GSP added new items at the end of each album, whether they were albums or media objects. This sometimes caused albums and media objects to be mixed together in a seemingly random fashion, making it hard to quickly find an item. In 2.4.6, albums are always shown at the beginning, and media objects are always shown at the end. This cannot be overridden, even with the rearrange function.

This is similar to how Windows sorts directories and files in Windows Explorer.

Allow keeping underlying file or directory when deleting objects

Starting in 2.4.6, one can delete an album or media object from the gallery without deleting the underlying directory or file. A new option appears on the Delete objects page:


Since the directory and media files aren’t deleted, they will re-appear if you synchronize the parent album. If you want to permanently prevent items from appearing in the gallery, but you don’t want to delete them from the server’s hard drive, use one of these tricks:

  • Mark the file or directory as hidden with a file utility such as Windows Explorer
  • Edit the NTFS permissions on the IIS application pool identity so that it does not have access to the file or directory.

More flexibility when choosing a thumbnail image for an album

You can now select from albums in addition to media objects when choosing a thumbnail image for an album. This lets you “bubble up” an image from a nested album:


More flexibility for generating captions for new media objects

Before 2.4.6, if GSP discovered a title embedded in the metadata of an image, it used that for the media object’s caption. If not found, it defaulted to the file name. That is still the default behavior in 2.4.6, but you can now change it if you want. A setting on the Metadata page (which is also new in 2.4.6) defines the template to use when assigning captions for newly added media objects:


As you can see, the default value is {Title}, but dozens of replacement tokens are supported. A complete list is found further down on the Metadata page. Here is a partial list:


For example, say you want the title and file size assigned as the default caption. Specify a template like this:


Then, when you add a media file, the caption is automatically assigned:


You can mix hard coded text as well as HTML in the template. Note: You must have the HTML editing option enabled if you want to use HTML in the template. (Do this on the User settings page.)

More metadata extracted from files, including IPTC and GPS properties

Several third party programs allow users to embed metadata in image files. This version has improved support for extracting IPTC metadata as well as GPS data.

Note that this functionality requires .NET 3.0 or higher and that the application be running in full trust.

GPS coordinates now link to Bing or Google Maps

When an image has GPS data, a link to Bing Maps is automatically created:


If you prefer to use Google Maps, no problem. Just update the template on the Metadata page. The popup help icon contains a pre-tested template that works with Google Maps.


Admin can specify order and visibility of metadata

Control which metadata items are visible and in what order in a new admin setting on the Metadata page:


Upgrade to jQuery 1.5 /jQuery path setting exposed in admin area

Now that jQuery 1.5 is out, GSP was updated to point to the latest version. And the setting was exposed in the Site Settings – General page to make it easier to change:


There are two things to note about the jQuery URL:

  1. It starts with “//”, not “http://”. This is intentional and helps improve caching performance while still supporting SSL scenarios. A good discussion can be found here.
  2. It doesn’t actually reference version 1.5. Instead, the “1” you see just before jquery.min.js indicates that any 1.* version is acceptable. By doing this, GSP will automatically stay up to date with the current version of jQuery – at least until version 2 is released. If you don’t like the uncertainty this brings to your gallery (because an update could break things), then update the path to specify a particular version.

Note also the admin exposes a setting for jQuery UI. jQuery UI was added for 2.4.6 and is currently used on the Metadata page to provide the cool drag and drop functionality. I anticipate expanding its usage in the future.

Additional application details shown in admin area

A few additional pieces of information are now shown on the Site Settings – General page:


Improved thread safety

Some refactoring was done to ensure that objects are updated and iterated in a thread-safe manner.

Added support for router port forwarding scenarios

Support was added for users who configure their router to forward requests on a particular port to an internal location that may be on a different port. For example, you might expose your gallery to the world at, but in your router configuration you send this traffic to port 80 of a local web server.

GSP now detects this situation and behaves appropriately. This required two changes:

  1. The external-facing address was explicitly assigned to all instances of the ComponentArt Callback control.
  2. URLs generated by the gallery (such as a welcome email) now reflect the external address, not the internal one.

Upgrade to latest version of SharpZipLib

A user reported that GSP could not unzip files created by Hotmail. This is actually handled by a third party library called SharpZipLib. I upgraded to the latest version with the hope that it would fix the problem, but it did not. However, with a little extra work, I coded a bug fix that seems to do the trick. This tweaked version of SharpZipLib is included in 2.4.6. I reported the potential bug to SharpZipLib and hopefully they’ll incorporate the bug fix in the core product.