Make sure your Image Media ContentTypes inherit from ImageResizer.Plugins.EPiFocalPoint.FocalPointImageData
, or implements ImageResizer.Plugins.EPiFocalPoint.IFocalPointData
if inheritance is inconvenient or undesired. Remember to decorate the FocalPoint property with [BackingType(typeof(PropertyFocalPoint))]
if you choose to implement the interface only.
Creating NuGet packages requires Visual Studio 2015.
Edit the image in AllPropertiesView, and place the red dot where you want it in the image.
An ImageResizing.NET plugin is installed in web.config
<resizer>
<plugins>
<add name="EPiFocalPointPlugin" />
</plugins>
</resizer>
ClientResources are installed (the editor needed for editors to place the focal point), along with some dojo stuff in module.config
<module>
<dojo>
<paths>
<add name="focal-point" path="focalpoint" />
</paths>
</dojo>
</module>
The coordinates of the focal point are stored as a ImageResizer.Plugins.EPiFocalPoint.SpecializedProperties.FocalPoint
property on the image.
The image dimensions are also stored in the properties OriginalWidth
and OriginalHeight
whenever the image is saved.
When the image is requested, the crop
parameter is added "under the hood", and then ImageResizing does its thing.
Embedded localizations are provided for Swedish and English. Should you need to localize in other languages, you can do so by adding XML translations thusly:
<contenttypes>
<imagedata>
<properties>
<focalpoint>
<caption>Focal point</caption>
<help>The point in the image, where the focus should be, automatically cropped images will be calculated based on this point.</help>
</focalpoint>
<originalheight>
<caption>Height</caption>
<help>The image height in pixels.</help>
</originalheight>
<originalwidth>
<caption>Width</caption>
<help>The image width in pixels.</help>
</originalwidth>
</properties>
</imagedata>
</contenttypes>
There are a few tests for the ImageDimensionService, more will be written as the need arises.
There are a few performance tests written to validate the usage of the ImageDimensionService, they are written using a simple StopWatch, but if you want Memory information they will need to be run using dotMemory. To benchmark performance on ayour specific number of files, drop them in the TestData/Benchmarks directory, and run the benchmark tests. As requirements differ, you can test with your amount of images, and see if this will work for you.
Initial release.