Extracting icons from a single image
Extracting icons from a single image
Question
I have purchased a set of icons.
In the package there are five files that contain all the icons, assembled on a regular grid in different file formats.
The file formats are .ai
, .eps
, .pdf
, .png
, .psd
.
I need the icons to use in an android application I'm writing. I need around twenty of them at different resolutions (32x32
, 48x48
, 64x64
& 96x96
), in .png
format.
The only way I know to extract the single icons is to do it by hand, but it would be a tedious and error-prone way.
Is there an automatic method, or a better way of getting the icons out of the files, at the various resolution I need?
What software will I need?
Ps. The icons i need to obtain have the following format:
As you can see, the icon is centered in a 64x64 bitmap. I have colored red the transparent part of the image to make it more visible.
Accepted Answer
Export objects from Inkscape as bitmaps
To export a vector object imported in Inkscape as a bitmap of defined pixel size we need the following steps:
Case source icons include background
Select the object with the select tool.
Export the object as bitmap ("File - Export Bitmap...").
Choose ""Export area - Selection" to only export the object.
- Define the pixel size (above 64 x 64) for the resulting bitmap.
- Choose a path and a filename for export.
Done.
Note: There is a batch option in Inkscape for exporting multiple selected objects in the "Custom" option but this will not let you define a fixed pixel size for each object.
Case source icon objects only
In case the source icons do not include a square box with margins the above steps will lead to a distorted icon when the object has a with different to height. We then need an additonal step to get desired results.
- Select object with the select tool.
- Copy the object to clipboard.
- Open a new document having the size of the source icons. In Inkscape you will have predefined layouts in the File - New menu (here I took
icon_32x32
). - Paste the clipboard content to the new document.
- Align the icon, e.g. to the center using the "Object - Align and Distribute..." tool.
- Export the page as bitmap with "File - Export Bitmap...".
- Choose "Page" and the desired bitmap sizes in the opening dialog (see above). We can export all sizes consecutively.