Jeffrey’s “Megapixel Sort” Lightroom Plugin

This plugin fills a specific need that some pro photographers have, which is the ability to sort images by their megapixel size, even after cropping.

This plugin works in Lightroom 6/CC (and older versions as far back as Lightroom 3, though some features depend on the version of Lightroom).

The same download works for both Windows and Mac. See the box to the upper right for the download link (in orange) and installation instructions.

Note: also see my powerful Data Explorer plugin, which lets you partition and group imgaes by 201 different data-related criteria, including image megapixels (both original and cropped)..

As shipped, Lightroom does have a “Megapixels” metadata item that is normally hidden, although it can be viewed by adding it to a metadata-viewer preset (such as with my Metadata-Viewer Preset Builder plugin). Unfortunately, that reflects the pixel size of the original image, not taking into account any crop that might have been applied. And even then, it's not among the items one can sort on, or even select via the Library Grid's Library Filter

Possible values for the
Megapixel Range
custom metadata item
not yet computed
< 0.5 MP
0.5 MP-0.99 MP
1 MP-1.99 MP
2 MP-3.99 MP
4 MP-5.99 MP
6 MP-7.99 MP
8 MP-11.99 MP
12 MP-15.99 MP
16 MP-23.99 MP
24 MP-31.99 MP
32 MP-47.99 MP
47 MP-63.99 MP
64 MP-99.99 MP
100 MP-199.99 MP
200 MP-349.99 MP
350 MP-499.99 MP
> 500 MP

Custom Metadata

This plugin creates two custom metadata items for each image it is applied to. The first, “Cropped Megapixels”, has values like 12.05 MP. The second, and “Megapixel Range”, has one of the values listed in the box at right.

Once this data has been calculated for each image (see below), it can be viewed via the “All Plug-in Metadata” preset in the Metadata panel of the Library Module.

Calculating and Recalculating

Unfortunately, the Lightroom plugin infrastructure does not yet allow for custom metadata to be created and updated automatically, so you must explicitly tell the plugin to calculate the custom metadata.

So, this plugin adds two items to the File > Plug-in Extras menu, “Calculate Megapixels” and “Calculate Megapixels For Entire Catalog”. The former calculates the two custom-metadata values for each selected image, while the latter does it for every image in the current catalog.

The plugin has no way of knowing when you make a cropping adjustment to an image, so you must remember to reapply the plugin to any images whose crop you change. That's a real hassle, and perhaps some future version of Lightroom will alleviate this burdensome requirement.

Still, even on my sort-of-old computer at home, the plugin can recalculate the data for my entire 45,000-image catalog in only about 30 seconds, so it's not that bad to just redo everything. Note that it's much more efficient to use “Calculate Megapixels for Entire Catalog” than selecting every image in the catalog and invoking “Calculate Megapixels”.

“Sorting” By Megapixel Size

You can't actually sort via megapixel size, even using this plugin, but you can use the Library Filter to do something close. The Library Filter is in the Grid Module; use the “/” key to bring it into view if it's not already visible.

(Be sure that you've calculated the plugin metadata, as described above, prior to this step.)

In the Library Filter, select “Metadata”, then click on one of the column heads and select “Megapixel Range”. You should then be presented with a list of the range items that apply to the currently-visible images. If they all have the same crop, they'll all be within one range, and so only one value will display. But if their image sizes or crop sizes put them into different ranges, multiple lines will show.

You can then click on one of the lines to isolate only the associated images.


This plugin is distributed as “donationware”. I have chosen to make it available for free — everyone can use it forever, without cost of any kind — but unless registered, its functionality is somewhat reduced after six weeks.

Registration is done via PayPal, and if you choose to register, it costs the minimum 1-cent PayPal fee; any amount you'd like to add beyond PayPal's sliding fees as a gift to me is completely optional, and completely appreciated.

Note: a Lightroom major upgrade, such as from Lr5 to Lr6, de-registers the plugin in the upgraded version, so if you want to maintain registration, a new ($0.01 if you like) registration code is needed in the upgraded version. It makes for a hassle every couple of years, I know. Sorry. See this note for details.

For details on plugin registration and on how I came into this hobby of Lightroom plugin development, see my Plugin Registration page.

Version History
( Update Log via RSS )


Try to avoid yet another place where Lightroom gets hung because it can't handle certain kinds of dialogs at the same time.


In the POODLE-vunerability dialog, display a raw URL of a page on my site that discusses the issue, so that folks can be independently sure that the dialog is indeed from me and not malware.

20141219.51 Registration was broken on Lr2
20141019.50 Windows Only: Add a one-time check for the POODLE security vulnerability, and alert the user if it exists.
20140902.49 New build system
20140731.48 Registration fix for Lr5.6
20140729.47 Previous updates broke support on Lightroom 2
20140720.46 More Creative-Cloud support.

Fixed an issue with Creative-Cloud revalidation.


Lr5.5 and later Creative-Cloud installs can now revalidate themselves if needed.

20140710.43 Sigh, had a bug in the Creative-Cloud support.

Now supports Lr5.5+ Creative-Cloud Installs.

20140704.41 Sigh, introduced an error for some folks with the rebuild the other day.
20140630.40 Build-system update

Added an "Expunge Plugin Data" section to the plugin manager, to allow plugin data to be cleared from the catalog.


Fixed a bug in the "smoother revalidation" stuff recently added.


Make the revalidation process smoother, especially for folks using Lr5.4 and later.

20130613.36 Better support for plugin revalidation.
20130611.35 Yet another Lr5 update
20130524.34 Apparently, a recent change broke things on Lr2, which some folks apparently still use.
20130501.33 Update for Lr5
20130412.32 Build system update.
20130328.31 Fix for the registration system.
20130209.30 More build-system maintenance
20130206.29 Tweak for my registration system
20120608.27 Fix an "attempt to perform arithmetic on field" error.

Update to handle the Mac App Store version of Lightroom.

Tweak for Lr4.1RC2.

Enhanced the send-log dialog to hopefully make reports more meaningful to me, yielding, I hope, the ability to respond more sensibly to more reports.

20120330.25 Update to handle 4.1RC
20120309.24 Had broken registrations in Lr2; Update to the debug logging to better track down timing issues that might arise.
20120304.23 More updates for Lr4.
20120221.22 More updates for Lr4.

More on the march toward Lr4, including upheaval in the code to handle Lightroom APIs being discontinued in Lr4.

20120114.19 More tweaks for Lr4b

Update for Lr4 beta: explain in the plugin manager that the plugin can't be registered in the beta.


Had issues with the registration button sometimes not showing.

When doing a plugin upgrade, offer the ability to flush all the old copies of the plugin.

Added a system-clock check and reports to the user if the system clock is more than a minute out of date. An incorrect system clock can cause problems with various kinds of communication and authentication with some of my plugins, so I've just gone ahead and added this to every plugin.

20100829.16 Made the revalidation process much simpler, doing away with the silly need for a revalidation file.
20100820.15 Discovered a bug in my plugin build system that caused horribly difficult-to-track-down errors in one plugin, so am pushing out rebuilt versions of all plugins just in case.
20100625.14 Yikes, shaking out some more build issues.
20100624.13 Discovered a nasty build bug; pushing a new version in case it affects this plugin.

This version can be registered in Lightroom 3. It can run in Lightroom 2 or Lightroom 3; it does not work in the Lr3 betas.

It uses my new registration system when run on Lightroom 3, which avoids some of the silly issues of the old one. Please take care to note the details on the registration page: use of this version (or later) of the plugin in Lightroom 3 requires a new registration code, even if you had registered some older version of the plugin.


Completely changed how the one-click upgrade applies the newly-downloaded zip file, in the hopes that it'll work for more people. Rather than unzipping over the old copy, it now unzips to a temporary folder, then moves the old folder out of the way and the new folder into place. Prior versions' folders are now maintained (with the version number in the folder) in case you want to revert a version; you may want to clear them out from time to time. Of course, it won't take affect until you try to upgrade after having upgraded to or beyond this version.

Wholesale changes that attempt to honor the user's locale settings for numeric display (e.g. Europeans writing 3,14156 for pi). I've probably missed some spots, so let me know if you find some.

20091214.10 Broke out the “< 0.5 MP” item into two, “< 0.1 MP” and “< 0.1 - 0.49 MP”. The change is not immediately reflected in photos that were processed earlier, so if you're interested in the new slice, you'll want to recompute MP for ones currently marked “< 0.5 MP”, or just recompute for your whole library.
20091205.9 Minor internal debugging tweaks.
20091022.8 Added a first draft of some rudimentary support for Lightroom 3 Beta. See this important note about plugin support in Lightroom 3 Beta and Lightroom 3, including future plans for features and my registration system.
20090802.7 Sigh, I shouldn't try to program while on vacation... the previous version was totoally broken. Trying again.
20090801.6 It seems that Lightroom reports that some images have no size (which makes no sense, of course), so I've added more debugging stuff to the log for these cases...
20090801.5 Corrects a few misspellings.

Expanded the upper end of the range from “> 64 MB” to “> 500 MP” to accommodate the fact that Lightroom can handle images up to 512 megapixels.

Enhanced the one-click upgrade stuff quite a bit, now detecting ahead of time when it will fail because the plugin is installed where Lightroom can't write (if Lightroom can't write to it, it can't update itself). I also added a progress bar, and now download in smaller chunks to avoid 'out of memory' errors on the larger plugins. Do remember that this new functionality becomes available after you upgrade to or past this version, when you then upgrade with it.

20090521.3 Fixed a "loadstring" error some users got.
20090510.2 Added a link in the Plugin Manager to the plugin's update-log RSS feed.
20090428.1 First public release.

All 13 comments so far, oldest first...

Hello, interesting plugin, do you think one that allow sorting by focal length would be possible as well? I find that lack in LR annoying (I even mentioned it on the Adobe forum…).

Cheers and thanks!

— comment by Ollivier Robert on June 22nd, 2009 at 7:18pm JST (6 years, 8 months ago) comment permalink

As Ollivier Robert suggested, it would really be usefull to allow sorting by focal length. It would then be possible to create Smart collections with different groups of focal lenghts. like 40mm, … or even tele, wide, …

The problem is that compact camera’s tend to record the compact focal length, so a 7mm would be in reality a 28mm for a 35mm camera. The 35mm equivalent should be then calculated one way or another. I believe there is an exif attribute holding the 35mm equivalent but I’m not sure.

— comment by Fabian Dierckxsens on June 24th, 2009 at 9:05pm JST (6 years, 8 months ago) comment permalink

Yes, I agree focal length filter/sorter would be a very useful.

— comment by Noel on July 25th, 2009 at 10:19pm JST (6 years, 7 months ago) comment permalink

Another vote for the Focal Length. Having just got a Leica M8 I really want to be able to filter based on the lens I used.

regards from the Stockholm archipelago.

— comment by Guy on October 11th, 2009 at 4:37am JST (6 years, 4 months ago) comment permalink

I can`t find how to get the cropped dimensions in lightroom SDK API. How did you managed?

Thank you

local size = photo:getRawMetadata('croppedDimensions')   —Jeffrey

— comment by Victor on October 17th, 2009 at 11:53pm JST (6 years, 4 months ago) comment permalink

Thanks a lot for the answer. It works fine. I don’t understand why it is not on the SDK documentation. Is there any additional source of information?

There’s a Lightroom SDK forum over at Adobe as well. —Jeffrey

— comment by Victor on October 20th, 2009 at 3:43am JST (6 years, 4 months ago) comment permalink

I need to be able to determine the UNCOMPRESSED size of a JPEG file.

My stock agency requires the JPEG, when opened in Photoshop or any other application, to be at least 48MB in file size. Is it possible to make a plugin that would calculate this?

For example, one of my JPEG files is caclulated by your plugin to be 12.1 Megapixels. The JPEG is 7.6MB. Opened in Photoshop, it’s 34.4MB.

The only two image editing programs that I know to give me this data are ACDSee Pro 3 and Photoshop. Sure would be nice to see it in Lightroom.


I don’t see how you’re getting 34.4MB from 12.1 MP (2.8 bytes/pixel?), but you can upsize on export to meet arbitrary size requirements. Tim Armes’ LR2/Mogrify plugin has some options to do this automatically. —Jeffrey

— comment by Alan Haynes on October 27th, 2009 at 2:56am JST (6 years, 3 months ago) comment permalink

Interesting plugin. I’m trying t find a way to sort by file size.

Essentially, I want to create a smart collection that shows me excessively large files (TIF and PSD) that are over a year old. My thought is that at that point, some/many/most of them can be flattened and I can reclaim hard drive real-estate. But I’m stymied by the lack of file size sort. Any suggestions?

The best I can suggest is to use the Library Grid Filter to isolate images that have not been edited in a while, then among those, use my Extended-Search plugin to isolate ones that have a large file size. —Jeffrey

— comment by Mark on August 17th, 2011 at 4:23am JST (4 years, 6 months ago) comment permalink

I was shocked to discover Lightroom doesn’t ship with this functionality built-in. Thank you so much for your work on this. The plugin works great.

— comment by David W on December 19th, 2011 at 2:52am JST (4 years, 2 months ago) comment permalink

I tried this plugin, and it does what it claims, but I find myself needing different “megapixel buckets” than it gives me.

While you could solve this by allowing the user to enter custom ranges, I think it would be better if the plugin could calculate optimum buckets by itself based on the population of photos in my particular library. For algorithm inspiration, I suggest looking into Heckbert color quantization. ( Instead of subdividing 3D color space, you’d be subdividing 1D megapixel space.

So you understand where I am coming from, my immediate need here is that I have a bunch of old photos in my library, scattered all over, and I want to start deleting or downrating ones that have too few megapixels by today’s standards. The < 0.1 MP bucket is minimally useful to me because I have very few photos that were that bad. The next bucket up (0.1-0.5 MP) catches too many photos I want to keep. I suspect I’d be most interested in removing things in the 0.2-0.3 MP range.

I think if you did a Heckbert-like automatic clump finder on the population of megapixel values in my library, you’d automatically generate a bucket in the right sort of range for my needs. It might be necessary to allow a custom number of buckets, to get enough resolution.

The problem is that Lightroom doesn’t allow any of this to be dynamic, so the best I can do is come up with something that seems useful to the most folks. It would be much better for Lightroom to deal with this as a first-class bit of metadata, so the plugin wasn’t needed at all. )-: —Jeffrey

— comment by Warren Young on January 3rd, 2012 at 11:04am JST (4 years, 1 month ago) comment permalink

Could the plugin be modified to allow sorting by actual mega pixel? Ranges are to vast, ability to sort by actual MP (and not ranges) would be very helpful.

Thank you

Not easily, no, sorry. —Jeffrey

— comment by Artur on September 13th, 2012 at 1:27pm JST (3 years, 5 months ago) comment permalink

Bonjour from Paris (France).

I am an amateur that takes a lot of pictures (mainly family, friends and public events). I also take a number of vidéos. My lightroom catalogue holds 50.000 pictures and 750 videos.

A suggestion for this plug-in is to also allow videos to be sorted by length and resolution.
For exemple:
Length: 0-10sec, 10.1sec-30sec, 30.1-60sec, 1-2mn, …
Resolution ranges: > 320 x 200 > 640 x 480 > 800 x 600 > 1024 x 768 > …

Merci for all your usefull plug-ins.

— comment by Luc on November 13th, 2012 at 7:09pm JST (3 years, 3 months ago) comment permalink

Me again; I just realised that your new Data Explorer plug-in allow for grouping by video length. I am just missing the resolution portion then !

I just pushed a new version that opens up “Dimensions” for videos. —Jeffrey

— comment by Luc on November 13th, 2012 at 7:18pm JST (3 years, 3 months ago) comment permalink
Leave a comment...

All comments are invisible to others until Jeffrey approves them.

Please mention what part of the world you're writing from, if you don't mind. It's always interesting to see where people are visiting from.

You can use the following tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Subscribe without commenting