- 0.2.0 and master18.104.22.168.04.2
- 0.2.0 and masteriOSmacOS(Intel)macOS(ARM)LinuxtvOSwatchOS
Adding images to iOS/macOS project is not straight forward. You should add
3x based on the screen size/ device. Your designer may give you the required
3x files. But what to do if they provide only one size or you downloading it from here. You should resize it with preview and rename, then add to assetcatalog. If you are continuosly adding/ changing images (especially during initial development stage), doing all these repeated tasks may become boring.
Assetizer will help you to do this tasks with a single line command.
$ git clone https://github.com/jkmathew/Assetizer.git $ cd Assetizer $ make
$ mint install jkmathew/Assetizer assetize
Add following line to your
dependencies: [ ..., .package(url: "https://github.com/jkmathew/Assetizer.git", .upToNextMajor(from: "0.1.0")) ]
$ assetize image.png --size 30x30
This will create
image.imageset, which can be directly used with your
Additionaly you can pass following options
--output - Output path, where you want to create the imageset.
If you are working on a project continuously, you can set default output directory by entering,
$ defaults write me.jkmathew.assetizer outputPath /path/to/images.xcassets
--output option not passed and no default directory set, will create imageset in the input directory.
--device - Target device family. Accepted values - [
Assetizer . Now you can use
AssetWriter class like.
let writer = try AssetWriter(imagePath: "/path/to/input.png", size: CGSize(width: 30, height: 30))// you can pass CGSize.zero to take size from input.png try writer.createAssets()
Johnykutty - firstname.lastname@example.org