SharePoint 2013: Image Rendition location & automation
This article won't just list how and where Image rendition stored in SharePoint 2013, it will provide a walk-through on how you can discover this on your own without relying on Google Search or any other blog posts.
If you are not familiar with the "Image Rendition Feature" which is newly introduced in SharePoint 2013 please refer to Waldek's excellent blog post here.
If you used image rendition before you will notice that the ID is not easily maintainable as it's a counter once you add a new item the ID is automatically given as the previous value+1.
Another important thing to share that in SharePoint 2013 there are two different kinds of Image rendition. The predefined ones which you define by navigating to site settings ->Image rendition. The other kind is what we call "on the fly" which you refer to an image by width and height. {ImageUrl}?width=300&height=150
For the second type, you can't update a specific picture's image rendition unless you already have a rendition predefined with the same dimensions.
To elaborate more in the below screenshot you can see an image rendered with width=300 and height =150 which is generated without predefined rendition.
https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http%3A%2F%2F4.bp.blogspot.com%2F-3q-dRy8WJe8%2FVM5Y81w5uhI%2FAAAAAAAAAmY%2FWkzXKyCB69A%2Fs1600%2F1.png&container=blogger&gadget=a&rewriteMime=image%2F*
https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http%3A%2F%2F3.bp.blogspot.com%2F--q74Oi-fZR8%2FVM5Y8Q_v0uI%2FAAAAAAAAAmU%2FHTWvm6qD9cw%2Fs1600%2F2.png&container=blogger&gadget=a&rewriteMime=image%2F*
Let's go back to the main point of the post which is how the image rendition is stored in the SP site collection.
If you have any decompiler like ILSPY just copy the ISAPI folder from your Hive 15 folder to ILSPY folder, load SharePoint assemblies, in particular, Microsoft.SharePoint.Publishing.dll, then in the search bar type rendition and wait for the results as shown below:
https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http%3A%2F%2F3.bp.blogspot.com%2F-eEQFOB78n6g%2FVM5a0RI4axI%2FAAAAAAAAAmo%2FhRY4XpIEP1g%2Fs1600%2F3.png&container=blogger&gadget=a&rewriteMime=image%2F*
Select the ImageRenditionCollection and choose SetRenditions Method
https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http%3A%2F%2F1.bp.blogspot.com%2F-td7CxBJGlyE%2FVM5a8DbqWFI%2FAAAAAAAAAmw%2FTOGZETF9cvI%2Fs1600%2F4.png&container=blogger&gadget=a&rewriteMime=image%2F*
In this method, you will find that the file been loaded and edited is located at the below path:
https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http%3A%2F%2F1.bp.blogspot.com%2F-TmXVBCYy1f0%2FVM5bAvVnLHI%2FAAAAAAAAAm4%2Fyx2uLrnSXoM%2Fs1600%2F5.png&container=blogger&gadget=a&rewriteMime=image%2F*
From the above, you can tell that the Rendition is stored in a single XML file under the masterpage folder.
As a conclusion to automate the creation of your predefined Image renditions you can add an XML file to a Module element and deploy the publishedImageRendition file to automate the creation of the image rendition instead of using the ImageRenditionCollection.Add Method in a feature activation code.
If you are using Office 365 you can either build a sandbox solution or refer to this post to use your App as module element to upload files to SharePoint using Remote event receiver.