Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
grunt-render-adaptive-icon
Advanced tools
Grunt plugin for rendering backwards compatible images from Android adaptive icons
Grunt plugin for rendering backwards compatible images from Android adaptive icons
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-render-adaptive-icon --save-dev
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-render-adaptive-icon');
In your project's Gruntfile, add a section named rendericon
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
rendericon: {
android_icons: {
options: {
foreground: 'example/template/foreground.png',
background: 'example/template/background.png',
mask: 'example/template/mask.png',
shadow: 'example/template/shadow.png',
crop: { width: 768, height: 768, left: 128, top: 128 }
},
files: [
{ width: 36, height: 36, dest: 'example/output/ldpi-icon.png' },
{ width: 48, height: 48, dest: 'example/output/mdpi-icon.png' },
{ width: 72, height: 72, dest: 'example/output/hdpi-icon.png' },
{ width: 96, height: 96, dest: 'example/output/xhdpi-icon.png' },
{ width: 144, height: 144, dest: 'example/output/xxhdpi-icon.png' },
{ width: 192, height: 192, dest: 'example/output/xxxhdpi-icon.png' },
{ width: 512, height: 512, dest: 'example/output/google-play.png', mask: false, crop: { width: 720, height: 720, left: 152, top: 152 } }
]
}
}
})
This plugin can be used to automatically generate backwards compatible versions of an Android adaptive icon. Adaptive icons consist of a foreground image and a background image which will be composited on top of each other. Different variants of Android will then use different shapes to cut out the actual icon. One variant might use circular icons, another squares, squares with rounded corners or squircles. See for more infomation the Android developer website.
For backwards capatibility it may be needed to also provide a regular old icon in various sizes. This plugin will automate that process.
In the first step a) the foreground will be composited on top of the background. In the next step b) the mask will be used to cut out the shape of the icon. In this case it will be a rounded rect. During step c) the resulting icon will be composited on top of the shadow. The next step is d) where the image will be cropped which results in our final icon, which will be scaled (e) to all the sizes specified.
In addition to these backwards compatible versions of the adaptive icon, we can also use the orignal icon assets to create a new Uniformed icon for the Play Store.
Uniformed icons that are submitted to the Play Store must be 512 x 512 pixels large and must not have a predefined shape. Instead it must be a square without any shadows. The Play Store will apply it's own rounded mask and shadow to ensure consistency across all app icons in the store.
In the last example of the configuration above you'll notice we are generating a 512 x 512 pixel version of the icon with masking turned off. We also use a slightly tighter crop compared to the other icons to make sure our artwork is properly sized.
Type: String
The foreground image for the adaptive icon. It would be best to use large version of the adaptive image as a base, for example 1024 x 1024 as we can use that scale down to all required sizes of icons while still maintaining a crisp image.
Type: String
The background image for the adaptive icon. It needs to be the same size of the foreground image.
Type: String
An image that will be used as a mask to cut out the icon in a particular shape. It needs to be the same size of the foreground image. The image needs to be transparent, with solid black for the area of the icon. An example image is provided in this repository. It needs to be the same size of the foreground image.
Type: String
An image that will be used to add a shadow behind the icon, if needed. An example image is provided in this repository.
Type: Object
Because adaptive icons contain extra space outside of the main safe area, the rendered icon needs to be cut to size. This object will contain width
, height
, top
and left
to determine the area that needs to be cut out. This area depends on the mask image that is provided.
A set of output file that will be generated from the source file. For each file the following settings can be defined:
Type Number
The width of the output image.
Type Number
The height of the output image.
Type: String
The path and name of the output file for that will be generated for this particular size.
Type: String
or Boolean
Overwrite the mask option for an individual output file. Can be false
to turn off masking for this file. This is especially useful to generate a new uniformed icon asset for the Play Store.
Type: String
or Boolean
Overwrite the shadow option of an individual output file.
Type: Object
Overwrite the crop option of an individual output file.
FAQs
Grunt plugin for rendering backwards compatible images from Android adaptive icons
We found that grunt-render-adaptive-icon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.