├── packages ├── makeanyicon │ ├── example │ │ ├── .gitignore │ │ ├── README.md │ │ ├── app_icon_1024.png │ │ └── makeanyicon_options.yaml │ ├── lib │ │ ├── makeanyicon.dart │ │ └── src │ │ │ ├── makeanyicon.dart │ │ │ └── makeanyicon_options.dart │ ├── .gitignore │ ├── CHANGELOG.md │ ├── pubspec.yaml │ ├── LICENSE │ ├── bin │ │ └── main.dart │ ├── pubspec.lock │ └── README.md └── any_icon_maker │ ├── lib │ ├── src │ │ ├── models │ │ │ ├── models.dart │ │ │ ├── image_set.dart │ │ │ └── image.dart │ │ ├── image_processor.dart │ │ ├── image_processor_adapter.dart │ │ ├── image_processor_adapter_magick.dart │ │ ├── image_processor_adapter_imglib.dart │ │ └── any_icon_maker.dart │ └── any_icon_maker.dart │ ├── .gitignore │ ├── CHANGELOG.md │ ├── pubspec.yaml │ ├── LICENSE │ ├── pubspec.lock │ └── README.md ├── .gitignore ├── melos.yaml ├── .all-contributorsrc └── README.md /packages/makeanyicon/example/.gitignore: -------------------------------------------------------------------------------- 1 | out/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | # IntelliJ related 4 | *.iml 5 | .idea/ -------------------------------------------------------------------------------- /melos.yaml: -------------------------------------------------------------------------------- 1 | name: makeanyicon 2 | 3 | packages: 4 | - packages/** 5 | -------------------------------------------------------------------------------- /packages/any_icon_maker/lib/src/models/models.dart: -------------------------------------------------------------------------------- 1 | export 'image_set.dart'; 2 | export 'image.dart'; 3 | -------------------------------------------------------------------------------- /packages/makeanyicon/example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | ``` 4 | makeanyicon --icon=app_icon_1024.png 5 | ``` 6 | -------------------------------------------------------------------------------- /packages/makeanyicon/lib/makeanyicon.dart: -------------------------------------------------------------------------------- 1 | export 'src/makeanyicon_options.dart'; 2 | export 'src/makeanyicon.dart'; 3 | -------------------------------------------------------------------------------- /packages/any_icon_maker/.gitignore: -------------------------------------------------------------------------------- 1 | .dart_tool/ 2 | .packages 3 | build/ 4 | pubspec.lock # Except for application packages 5 | -------------------------------------------------------------------------------- /packages/makeanyicon/.gitignore: -------------------------------------------------------------------------------- 1 | .dart_tool/ 2 | .packages 3 | build/ 4 | pubspec.lock # Except for application packages 5 | -------------------------------------------------------------------------------- /packages/makeanyicon/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 2 | 3 | - Make some improvements 4 | 5 | ## 0.0.1 6 | 7 | - First release. 8 | -------------------------------------------------------------------------------- /packages/any_icon_maker/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 2 | 3 | - #1 Add processing method switch 4 | 5 | ## 0.0.1 6 | 7 | - First release. 8 | -------------------------------------------------------------------------------- /packages/makeanyicon/example/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lijy91-archives-repos/makeanyicon/HEAD/packages/makeanyicon/example/app_icon_1024.png -------------------------------------------------------------------------------- /packages/any_icon_maker/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: any_icon_maker 2 | description: A configurable icon maker. 3 | version: 0.1.0 4 | homepage: https://github.com/makeanyicon/any_icon_maker 5 | 6 | environment: 7 | sdk: ">=2.12.0 <3.0.0" 8 | 9 | dependencies: 10 | image: ^3.0.5 11 | -------------------------------------------------------------------------------- /packages/any_icon_maker/lib/any_icon_maker.dart: -------------------------------------------------------------------------------- 1 | export 'src/models/models.dart'; 2 | export 'src/any_icon_maker.dart'; 3 | export 'src/image_processor_adapter_imglib.dart'; 4 | export 'src/image_processor_adapter_magick.dart'; 5 | export 'src/image_processor_adapter.dart'; 6 | export 'src/image_processor.dart'; 7 | -------------------------------------------------------------------------------- /packages/makeanyicon/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: makeanyicon 2 | description: Command-line Interface (CLI) for any_icon_maker. 3 | version: 0.1.0 4 | homepage: https://github.com/makeanyicon/makeanyicon 5 | 6 | environment: 7 | sdk: ">=2.12.0 <3.0.0" 8 | 9 | dependencies: 10 | any_icon_maker: ^0.1.0 11 | args: ^2.2.0 12 | image: ^3.0.5 13 | yaml: ^3.1.0 14 | 15 | executables: 16 | makeanyicon: main 17 | -------------------------------------------------------------------------------- /packages/any_icon_maker/lib/src/image_processor.dart: -------------------------------------------------------------------------------- 1 | import 'image_processor_adapter.dart'; 2 | 3 | class ImageProcessor { 4 | final ImageProcessorAdapter adapter; 5 | 6 | ImageProcessor(this.adapter); 7 | 8 | ImageProcessor load(String path) { 9 | adapter.load(path); 10 | return this; 11 | } 12 | 13 | ImageProcessor resize(int width, int height) { 14 | adapter.resize(width, height); 15 | return this; 16 | } 17 | 18 | void save(String outPath) { 19 | adapter.save(outPath); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/any_icon_maker/lib/src/image_processor_adapter.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | class ImageProcessorAdapter { 4 | File? originImageFile; 5 | int? resizeWidth; 6 | int? resizeHeight; 7 | 8 | ImageProcessorAdapter load(String path) { 9 | originImageFile = File(path); 10 | resizeWidth = null; 11 | resizeHeight = null; 12 | return this; 13 | } 14 | 15 | ImageProcessorAdapter resize(int width, int height) { 16 | resizeWidth = width; 17 | resizeHeight = height; 18 | return this; 19 | } 20 | 21 | void save(String outPath) { 22 | throw UnimplementedError(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/makeanyicon/lib/src/makeanyicon.dart: -------------------------------------------------------------------------------- 1 | import 'package:any_icon_maker/any_icon_maker.dart'; 2 | 3 | import 'makeanyicon_options.dart'; 4 | 5 | class MakeAnyIcon { 6 | MakeAnyIcon._(); 7 | 8 | /// The shared instance of [MakeAnyIcon]. 9 | static final MakeAnyIcon instance = MakeAnyIcon._(); 10 | 11 | Future make( 12 | String iconPath, 13 | MakeAnyIconOptions options, { 14 | ImageProcessingMethod method: ImageProcessingMethod.imgLib, 15 | }) async { 16 | final anyIconMaker = AnyIconMaker(); 17 | await anyIconMaker.make( 18 | iconPath, 19 | options.outputPath, 20 | options.imageSets, 21 | method: method, 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "README.md" 4 | ], 5 | "imageSize": 100, 6 | "commit": false, 7 | "commitConvention": "angular", 8 | "contributors": [ 9 | { 10 | "login": "westito", 11 | "name": "westito", 12 | "avatar_url": "https://avatars.githubusercontent.com/u/536799?v=4", 13 | "profile": "https://github.com/westito", 14 | "contributions": [ 15 | "infra", 16 | "test", 17 | "code" 18 | ] 19 | } 20 | ], 21 | "contributorsPerLine": 7, 22 | "skipCi": true, 23 | "repoType": "github", 24 | "repoHost": "https://github.com", 25 | "projectName": "makeanyicon", 26 | "projectOwner": "leanflutter" 27 | } 28 | -------------------------------------------------------------------------------- /packages/any_icon_maker/lib/src/image_processor_adapter_magick.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'image_processor_adapter.dart'; 4 | 5 | class ImageProcessorAdapterMagick extends ImageProcessorAdapter { 6 | @override 7 | void save(String outPath) { 8 | File outputFile = File(outPath); 9 | if (!outputFile.parent.existsSync()) { 10 | outputFile.parent.createSync(recursive: true); 11 | } 12 | ProcessResult processResult = Process.runSync( 13 | 'magick', 14 | [ 15 | originImageFile!.path, 16 | '-resize', 17 | '${resizeWidth}x$resizeHeight', 18 | outPath, 19 | ], 20 | runInShell: true, 21 | ); 22 | 23 | if (processResult.exitCode != 0) { 24 | throw Exception(processResult.stderr as String); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/any_icon_maker/lib/src/models/image_set.dart: -------------------------------------------------------------------------------- 1 | import 'image.dart'; 2 | 3 | class ImageSet { 4 | final String name; 5 | final String path; 6 | final List images; 7 | 8 | ImageSet({ 9 | required this.name, 10 | required this.path, 11 | required this.images, 12 | }); 13 | 14 | factory ImageSet.fromJson(Map json) { 15 | List images = (json['images'] as List) 16 | .map((item) => Image.fromJson(Map.from(item))) 17 | .toList(); 18 | 19 | return ImageSet( 20 | name: json['name'], 21 | path: json['path'], 22 | images: images, 23 | ); 24 | } 25 | 26 | Map toJson() { 27 | return { 28 | 'name': name, 29 | 'path': path, 30 | 'images': images.map((e) => e.toJson()), 31 | }; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/any_icon_maker/lib/src/models/image.dart: -------------------------------------------------------------------------------- 1 | class Image { 2 | String size; 3 | int scale; 4 | String path; 5 | String filename; 6 | 7 | double get _width => double.parse(size.split('x')[0]); 8 | double get _height => double.parse(size.split('x')[1]); 9 | 10 | double get width => _width * scale; 11 | double get height => _height * scale; 12 | 13 | Image({ 14 | required this.size, 15 | this.scale = 1, 16 | this.path = '', 17 | required this.filename, 18 | }); 19 | 20 | factory Image.fromJson(Map json) { 21 | return Image( 22 | size: json['size'], 23 | scale: int.parse((json['scale'] ?? '1x').replaceFirst('x', '')), 24 | path: json['path'] ?? '', 25 | filename: json['filename'], 26 | ); 27 | } 28 | 29 | Map toJson() { 30 | return { 31 | 'size': size, 32 | 'scale': '${scale}x', 33 | 'path': path, 34 | 'filename': filename, 35 | }; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/any_icon_maker/lib/src/image_processor_adapter_imglib.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:image/image.dart' as imglib; 4 | 5 | import 'image_processor_adapter.dart'; 6 | 7 | class ImageProcessorAdapterImglib extends ImageProcessorAdapter { 8 | @override 9 | void save(String outPath) { 10 | imglib.Image originImage = 11 | imglib.decodePng(originImageFile!.readAsBytesSync())!; 12 | 13 | var resizedImage = imglib.copyResize( 14 | originImage, 15 | width: resizeWidth, 16 | height: resizeHeight, 17 | interpolation: imglib.Interpolation.average, 18 | ); 19 | 20 | File outputFile = File(outPath); 21 | if (!outputFile.parent.existsSync()) { 22 | outputFile.parent.createSync(recursive: true); 23 | } 24 | List resizedImageData; 25 | if (outPath.split("/").last.contains('.ico')) { 26 | resizedImageData = imglib.encodeIco(resizedImage); 27 | } else { 28 | resizedImageData = imglib.encodePng(resizedImage); 29 | } 30 | outputFile.writeAsBytesSync(resizedImageData); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/makeanyicon/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 LiJianying 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/any_icon_maker/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 LiJianying 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/any_icon_maker/lib/src/any_icon_maker.dart: -------------------------------------------------------------------------------- 1 | import '../any_icon_maker.dart'; 2 | import 'image_processor.dart'; 3 | import 'models/models.dart'; 4 | 5 | enum ImageProcessingMethod { imgLib, magick } 6 | 7 | class AnyIconMaker { 8 | Future make( 9 | String iconPath, 10 | String outputPath, 11 | List imageSetList, { 12 | ImageProcessingMethod method: ImageProcessingMethod.imgLib, 13 | }) async { 14 | ImageProcessorAdapter imageProcessorAdapter; 15 | if (method == ImageProcessingMethod.magick) { 16 | imageProcessorAdapter = ImageProcessorAdapterMagick(); 17 | } else { 18 | imageProcessorAdapter = ImageProcessorAdapterImglib(); 19 | } 20 | 21 | for (ImageSet imageSet in imageSetList) { 22 | for (Image image in imageSet.images) { 23 | String imagePath = [ 24 | outputPath, 25 | imageSet.path, 26 | image.path, 27 | image.filename, 28 | ].join(''); 29 | 30 | ImageProcessor(imageProcessorAdapter) 31 | .load(iconPath) 32 | .resize(image.width.toInt(), image.height.toInt()) 33 | .save(imagePath); 34 | 35 | print('Success: $imagePath'); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/any_icon_maker/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | archive: 5 | dependency: transitive 6 | description: 7 | name: archive 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "3.1.2" 11 | collection: 12 | dependency: transitive 13 | description: 14 | name: collection 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "1.15.0" 18 | crypto: 19 | dependency: transitive 20 | description: 21 | name: crypto 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "3.0.1" 25 | image: 26 | dependency: "direct main" 27 | description: 28 | name: image 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "3.0.5" 32 | meta: 33 | dependency: transitive 34 | description: 35 | name: meta 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.7.0" 39 | path: 40 | dependency: transitive 41 | description: 42 | name: path 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.8.0" 46 | petitparser: 47 | dependency: transitive 48 | description: 49 | name: petitparser 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "4.1.0" 53 | typed_data: 54 | dependency: transitive 55 | description: 56 | name: typed_data 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.3.0" 60 | xml: 61 | dependency: transitive 62 | description: 63 | name: xml 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "5.1.2" 67 | sdks: 68 | dart: ">=2.12.0 <3.0.0" 69 | -------------------------------------------------------------------------------- /packages/any_icon_maker/README.md: -------------------------------------------------------------------------------- 1 | # any_icon_maker 2 | 3 | [![pub version][pub-image]][pub-url] 4 | 5 | [pub-image]: https://img.shields.io/pub/v/any_icon_maker.svg 6 | [pub-url]: https://pub.dev/packages/any_icon_maker 7 | 8 | A configurable icon maker. 9 | 10 | --- 11 | 12 | 13 | 14 | 15 | 16 | - [any_icon_maker](#any_icon_maker) 17 | - [Quick Start](#quick-start) 18 | - [Installation](#installation) 19 | - [Usage](#usage) 20 | - [License](#license) 21 | 22 | 23 | 24 | ## Quick Start 25 | 26 | ### Installation 27 | 28 | Add this to your package's pubspec.yaml file: 29 | 30 | ```yaml 31 | dependencies: 32 | any_icon_maker: ^0.1.0 33 | ``` 34 | 35 | Or 36 | 37 | ```yaml 38 | dependencies: 39 | window_manager: 40 | git: 41 | url: https://github.com/makeanyicon/any_icon_maker.git 42 | ref: main 43 | ``` 44 | 45 | ### Usage 46 | 47 | ```dart 48 | import 'package:any_icon_maker/any_icon_maker.dart'; 49 | 50 | Future main(List args) async { 51 | String iconPath = 'app_icon_1024.png'; 52 | String outputPath = ''; // Save to current directory 53 | List imageSets = [ 54 | ImageSet( 55 | name: 'web', 56 | path: 'public/', 57 | images: [ 58 | Image(size: '48x48', filename: 'favicon.ico'), 59 | Image(size: '192x192', filename: 'logo192.png'), 60 | Image(size: '512x512', filename: 'logo512.png'), 61 | ], 62 | ), 63 | ]; 64 | final anyIconMaker = AnyIconMaker(); 65 | await anyIconMaker.make(iconPath, outputPath, imageSets); 66 | } 67 | ``` 68 | 69 | ## License 70 | 71 | [MIT](./LICENSE) 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # makeanyicon 2 | 3 | [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-) 4 | 5 | 6 | A configurable icon maker. 7 | 8 | --- 9 | 10 | ## Packages 11 | 12 | These are the available packages in this repository. 13 | 14 | | Package | Pub | 15 | | -------------------------------------------- | ----------------------------------------------------------------------------------------------- | 16 | | [any_icon_maker](./packages/any_icon_maker/) | [![](https://img.shields.io/pub/v/any_icon_maker.svg)](https://pub.dev/packages/any_icon_maker) | 17 | | [makeanyicon](./packages/makeanyicon/) | [![](https://img.shields.io/pub/v/makeanyicon.svg)](https://pub.dev/packages/makeanyicon) | 18 | ## Contributors ✨ 19 | 20 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
westito
westito

🚇 ⚠️ 💻
32 | 33 | 34 | 35 | 36 | 37 | 38 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! -------------------------------------------------------------------------------- /packages/makeanyicon/bin/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:any_icon_maker/any_icon_maker.dart'; 4 | import 'package:args/args.dart'; 5 | import 'package:makeanyicon/makeanyicon.dart'; 6 | 7 | Future main(List args) async { 8 | final parser = ArgParser(); 9 | 10 | parser.addFlag( 11 | 'help', 12 | abbr: 'h', 13 | negatable: false, 14 | ); 15 | 16 | parser.addOption( 17 | 'input', 18 | abbr: 'i', 19 | valueHelp: 'path', 20 | help: 'Input image (1024x1024 PNG recommended)', 21 | ); 22 | 23 | parser.addOption( 24 | 'method', 25 | abbr: 'm', 26 | valueHelp: 'method', 27 | help: 'Image processing method', 28 | defaultsTo: 'imglib', 29 | allowed: [ 30 | 'imglib', 31 | 'magick', 32 | ], 33 | allowedHelp: { 34 | 'imglib': 'Use Dart image library', 35 | 'magick': 'Use local magick (must be installed)', 36 | }, 37 | ); 38 | 39 | parser.addOption( 40 | 'options', 41 | abbr: 'f', 42 | valueHelp: 'makeanyicon_options.yaml', 43 | help: 'Options yaml file (defaults to example yaml)', 44 | ); 45 | 46 | parser.addOption( 47 | 'output', 48 | abbr: 'o', 49 | valueHelp: 'output path', 50 | help: 'Images output directory (defaults to current directory)', 51 | ); 52 | 53 | final options = parser.parse(args); 54 | 55 | if (options['help'] == true) { 56 | print('Usage: makeanyicon --input=app_icon_1024.png\n'); 57 | print(parser.usage); 58 | return; 59 | } 60 | 61 | final inputArg = options['input'] as String?; 62 | if (inputArg == null || inputArg == '') { 63 | throw ArgumentError('Input file not provided'); 64 | } 65 | 66 | if (!inputArg.endsWith('.png')) { 67 | throw ArgumentError('Input image is not a PNG file.'); 68 | } 69 | 70 | final inputImage = File(inputArg); 71 | if (!inputImage.existsSync()) { 72 | throw ArgumentError('Input image not exists.'); 73 | } 74 | 75 | final optionsArg = options['options'] as String?; 76 | if (optionsArg != null && 77 | !(optionsArg.endsWith('.yaml') || optionsArg.endsWith('.yaml'))) { 78 | throw ArgumentError('Options file provided is not a YAML file'); 79 | } 80 | 81 | final optionsFile = optionsArg != null ? File(optionsArg) : null; 82 | if (optionsFile != null && !optionsFile.existsSync()) { 83 | throw ArgumentError('Options file provided is not exists.'); 84 | } 85 | 86 | ImageProcessingMethod method; 87 | switch (options['method']) { 88 | case 'magick': 89 | method = ImageProcessingMethod.magick; 90 | break; 91 | case 'imglib': 92 | case null: 93 | method = ImageProcessingMethod.imgLib; 94 | break; 95 | default: 96 | print('Invalid method parameter!\n'); 97 | return; 98 | } 99 | 100 | await MakeAnyIcon.instance.make( 101 | inputArg, 102 | MakeAnyIconOptions.fromFile(optionsFile, options['output'] ?? ''), 103 | method: method, 104 | ); 105 | } 106 | -------------------------------------------------------------------------------- /packages/makeanyicon/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | any_icon_maker: 5 | dependency: "direct main" 6 | description: 7 | name: any_icon_maker 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "0.1.0" 11 | archive: 12 | dependency: transitive 13 | description: 14 | name: archive 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "3.1.2" 18 | args: 19 | dependency: "direct main" 20 | description: 21 | name: args 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "2.2.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.3.1" 32 | collection: 33 | dependency: transitive 34 | description: 35 | name: collection 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.15.0" 39 | crypto: 40 | dependency: transitive 41 | description: 42 | name: crypto 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "3.0.1" 46 | image: 47 | dependency: "direct main" 48 | description: 49 | name: image 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "3.0.5" 53 | meta: 54 | dependency: transitive 55 | description: 56 | name: meta 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.7.0" 60 | path: 61 | dependency: transitive 62 | description: 63 | name: path 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "1.8.0" 67 | petitparser: 68 | dependency: transitive 69 | description: 70 | name: petitparser 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "4.1.0" 74 | source_span: 75 | dependency: transitive 76 | description: 77 | name: source_span 78 | url: "https://pub.dartlang.org" 79 | source: hosted 80 | version: "1.8.1" 81 | string_scanner: 82 | dependency: transitive 83 | description: 84 | name: string_scanner 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "1.1.0" 88 | term_glyph: 89 | dependency: transitive 90 | description: 91 | name: term_glyph 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "1.2.0" 95 | typed_data: 96 | dependency: transitive 97 | description: 98 | name: typed_data 99 | url: "https://pub.dartlang.org" 100 | source: hosted 101 | version: "1.3.0" 102 | xml: 103 | dependency: transitive 104 | description: 105 | name: xml 106 | url: "https://pub.dartlang.org" 107 | source: hosted 108 | version: "5.1.2" 109 | yaml: 110 | dependency: "direct main" 111 | description: 112 | name: yaml 113 | url: "https://pub.dartlang.org" 114 | source: hosted 115 | version: "3.1.0" 116 | sdks: 117 | dart: ">=2.12.0 <3.0.0" 118 | -------------------------------------------------------------------------------- /packages/makeanyicon/example/makeanyicon_options.yaml: -------------------------------------------------------------------------------- 1 | image_sets: 2 | - name: android 3 | path: android/app/src/main/res/ 4 | images: 5 | - size: 48x48 6 | path: mipmap-mdpi/ 7 | filename: ic_launcher.png 8 | - size: 72x72 9 | path: mipmap-hdpi/ 10 | filename: ic_launcher.png 11 | - size: 96x96 12 | path: mipmap-xhdpi/ 13 | filename: ic_launcher.png 14 | - size: 144x144 15 | path: mipmap-xxhdpi/ 16 | filename: ic_launcher.png 17 | - size: 192x192 18 | path: mipmap-xxxhdpi/ 19 | filename: ic_launcher.png 20 | - name: ios 21 | path: ios/Runner/Assets.xcassets/AppIcon.appiconset/ 22 | images: 23 | - size: 20x20 24 | scale: 1x 25 | filename: Icon-App-20x20@1x.png 26 | - size: 20x20 27 | scale: 2x 28 | filename: Icon-App-20x20@2x.png 29 | - size: 20x20 30 | scale: 3x 31 | filename: Icon-App-20x20@3x.png 32 | - size: 29x29 33 | scale: 1x 34 | filename: Icon-App-29x29@1x.png 35 | - size: 29x29 36 | scale: 2x 37 | filename: Icon-App-29x29@2x.png 38 | - size: 29x29 39 | scale: 3x 40 | filename: Icon-App-29x29@3x.png 41 | - size: 40x40 42 | scale: 1x 43 | filename: Icon-App-40x40@1x.png 44 | - size: 40x40 45 | scale: 2x 46 | filename: Icon-App-40x40@2x.png 47 | - size: 40x40 48 | scale: 3x 49 | filename: Icon-App-40x40@3x.png 50 | - size: 60x60 51 | scale: 1x 52 | filename: Icon-App-60x60@1x.png 53 | - size: 60x60 54 | scale: 2x 55 | filename: Icon-App-60x60@2x.png 56 | - size: 60x60 57 | scale: 3x 58 | filename: Icon-App-60x60@3x.png 59 | - size: 76x76 60 | scale: 1x 61 | filename: Icon-App-76x76@1x.png 62 | - size: 76x76 63 | scale: 2x 64 | filename: Icon-App-76x76@2x.png 65 | - size: 83.5x83.5 66 | scale: 2x 67 | filename: Icon-App-83.5x83.5@2x.png 68 | - size: 1024x1024 69 | scale: 1x 70 | filename: Icon-App-1024x1024@1x.png 71 | - name: macos 72 | path: macos/Runner/Assets.xcassets/AppIcon.appiconset/ 73 | images: 74 | - size: 16x16 75 | scale: 1x 76 | filename: app_icon_16.png 77 | - size: 32x32 78 | scale: 1x 79 | filename: app_icon_32.png 80 | - size: 64x64 81 | scale: 1x 82 | filename: app_icon_64.png 83 | - size: 128x128 84 | scale: 1x 85 | filename: app_icon_128.png 86 | - size: 256x256 87 | scale: 1x 88 | filename: app_icon_256.png 89 | - size: 512x512 90 | scale: 1x 91 | filename: app_icon_512.png 92 | - size: 1024x1024 93 | scale: 1x 94 | filename: app_icon_1024.png 95 | - name: web 96 | path: web/ 97 | images: 98 | - size: 16x16 99 | filename: favicon.png 100 | - size: 192x192 101 | path: icons/ 102 | filename: Icon-192.png 103 | - size: 512x512 104 | path: icons/ 105 | filename: Icon-512.png 106 | - size: 192x192 107 | path: icons/ 108 | filename: Icon-maskable-192.png 109 | - size: 512x512 110 | path: icons/ 111 | filename: Icon-maskable-512.png 112 | - name: windows 113 | path: windows/runner/resources/ 114 | images: 115 | - size: 256x256 116 | filename: app_icon.ico 117 | -------------------------------------------------------------------------------- /packages/makeanyicon/README.md: -------------------------------------------------------------------------------- 1 | # makeanyicon 2 | 3 | [![pub version][pub-image]][pub-url] 4 | 5 | [pub-image]: https://img.shields.io/pub/v/makeanyicon.svg 6 | [pub-url]: https://pub.dev/packages/makeanyicon 7 | 8 | Command-line Interface (CLI) for [any_icon_maker](https://github.com/makeanyicon/any_icon_maker). 9 | 10 | --- 11 | 12 | 13 | 14 | 15 | - [makeanyicon](#makeanyicon) 16 | - [Quick Start](#quick-start) 17 | - [Installation](#installation) 18 | - [Usage](#usage) 19 | - [License](#license) 20 | 21 | 22 | 23 | ## Quick Start 24 | 25 | ### Installation 26 | 27 | ``` 28 | dart pub global activate makeanyicon 29 | ``` 30 | 31 | ### Usage 32 | 33 | Add `makeanyicon_options.yaml` to your project root directory. 34 | 35 | `makeanyicon_options.yaml`: 36 | 37 | ```yaml 38 | image_sets: 39 | - name: android 40 | path: android/app/src/main/res/ 41 | images: 42 | - size: 48x48 43 | path: mipmap-mdpi/ 44 | filename: ic_launcher.png 45 | - size: 72x72 46 | path: mipmap-hdpi/ 47 | filename: ic_launcher.png 48 | - size: 96x96 49 | path: mipmap-xhdpi/ 50 | filename: ic_launcher.png 51 | - size: 144x144 52 | path: mipmap-xxhdpi/ 53 | filename: ic_launcher.png 54 | - size: 192x192 55 | path: mipmap-xxxhdpi/ 56 | filename: ic_launcher.png 57 | - name: ios 58 | path: ios/Runner/Assets.xcassets/AppIcon.appiconset/ 59 | images: 60 | - size: 20x20 61 | scale: 1x 62 | filename: Icon-App-20x20@1x.png 63 | - size: 20x20 64 | scale: 2x 65 | filename: Icon-App-20x20@2x.png 66 | - size: 20x20 67 | scale: 3x 68 | filename: Icon-App-20x20@3x.png 69 | - size: 29x29 70 | scale: 1x 71 | filename: Icon-App-29x29@1x.png 72 | - size: 29x29 73 | scale: 2x 74 | filename: Icon-App-29x29@2x.png 75 | - size: 29x29 76 | scale: 3x 77 | filename: Icon-App-29x29@3x.png 78 | - size: 40x40 79 | scale: 1x 80 | filename: Icon-App-40x40@1x.png 81 | - size: 40x40 82 | scale: 2x 83 | filename: Icon-App-40x40@2x.png 84 | - size: 40x40 85 | scale: 3x 86 | filename: Icon-App-40x40@3x.png 87 | - size: 60x60 88 | scale: 1x 89 | filename: Icon-App-60x60@1x.png 90 | - size: 60x60 91 | scale: 2x 92 | filename: Icon-App-60x60@2x.png 93 | - size: 60x60 94 | scale: 3x 95 | filename: Icon-App-60x60@3x.png 96 | - size: 76x76 97 | scale: 1x 98 | filename: Icon-App-76x76@1x.png 99 | - size: 76x76 100 | scale: 2x 101 | filename: Icon-App-76x76@2x.png 102 | - size: 83.5x83.5 103 | scale: 2x 104 | filename: Icon-App-83.5x83.5@2x.png 105 | - size: 1024x1024 106 | scale: 1x 107 | filename: Icon-App-1024x1024@1x.png 108 | - name: macos 109 | path: macos/Runner/Assets.xcassets/AppIcon.appiconset/ 110 | images: 111 | - size: 16x16 112 | scale: 1x 113 | filename: app_icon_16.png 114 | - size: 32x32 115 | scale: 1x 116 | filename: app_icon_32.png 117 | - size: 64x64 118 | scale: 1x 119 | filename: app_icon_64.png 120 | - size: 128x128 121 | scale: 1x 122 | filename: app_icon_128.png 123 | - size: 256x256 124 | scale: 1x 125 | filename: app_icon_256.png 126 | - size: 512x512 127 | scale: 1x 128 | filename: app_icon_512.png 129 | - size: 1024x1024 130 | scale: 1x 131 | filename: app_icon_1024.png 132 | - name: web 133 | path: web/ 134 | images: 135 | - size: 16x16 136 | filename: favicon.png 137 | - size: 192x192 138 | path: icons/ 139 | filename: Icon-192.png 140 | - size: 512x512 141 | path: icons/ 142 | filename: Icon-512.png 143 | - size: 192x192 144 | path: icons/ 145 | filename: Icon-maskable-192.png 146 | - size: 512x512 147 | path: icons/ 148 | filename: Icon-maskable-512.png 149 | - name: windows 150 | path: windows/runner/resources/ 151 | images: 152 | - size: 256x256 153 | filename: app_icon.ico 154 | ``` 155 | 156 | Run: 157 | 158 | ``` 159 | makeanyicon --input=app_icon_1024.png 160 | ``` 161 | 162 | ## License 163 | 164 | [MIT](./LICENSE) 165 | -------------------------------------------------------------------------------- /packages/makeanyicon/lib/src/makeanyicon_options.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | 4 | import 'package:any_icon_maker/any_icon_maker.dart'; 5 | import 'package:yaml/yaml.dart'; 6 | 7 | class MakeAnyIconOptions { 8 | final String outputPath; 9 | final List imageSets; 10 | 11 | MakeAnyIconOptions({ 12 | required this.outputPath, 13 | required this.imageSets, 14 | }); 15 | 16 | factory MakeAnyIconOptions.fromFile(File? file, String output) { 17 | final options = loadYaml(file?.readAsStringSync() ?? _defaultYaml); 18 | return MakeAnyIconOptions.fromJson( 19 | json.decode(json.encode(options)), output); 20 | } 21 | 22 | factory MakeAnyIconOptions.fromJson( 23 | Map json, 24 | String output, 25 | ) { 26 | List imageSets = (json['image_sets'] as List) 27 | .map((item) => ImageSet.fromJson(Map.from(item))) 28 | .toList(); 29 | 30 | return MakeAnyIconOptions( 31 | outputPath: output, 32 | imageSets: imageSets, 33 | ); 34 | } 35 | 36 | Map toJson() { 37 | return { 38 | 'output': outputPath, 39 | 'image_sets': imageSets.map((e) => e.toJson()), 40 | }; 41 | } 42 | } 43 | 44 | const _defaultYaml = ''' 45 | image_sets: 46 | - name: android 47 | path: android/app/src/main/res/ 48 | images: 49 | - size: 48x48 50 | path: mipmap-mdpi/ 51 | filename: ic_launcher.png 52 | - size: 72x72 53 | path: mipmap-hdpi/ 54 | filename: ic_launcher.png 55 | - size: 96x96 56 | path: mipmap-xhdpi/ 57 | filename: ic_launcher.png 58 | - size: 144x144 59 | path: mipmap-xxhdpi/ 60 | filename: ic_launcher.png 61 | - size: 192x192 62 | path: mipmap-xxxhdpi/ 63 | filename: ic_launcher.png 64 | - name: ios 65 | path: ios/Runner/Assets.xcassets/AppIcon.appiconset/ 66 | images: 67 | - size: 20x20 68 | scale: 1x 69 | filename: Icon-App-20x20@1x.png 70 | - size: 20x20 71 | scale: 2x 72 | filename: Icon-App-20x20@2x.png 73 | - size: 20x20 74 | scale: 3x 75 | filename: Icon-App-20x20@3x.png 76 | - size: 29x29 77 | scale: 1x 78 | filename: Icon-App-29x29@1x.png 79 | - size: 29x29 80 | scale: 2x 81 | filename: Icon-App-29x29@2x.png 82 | - size: 29x29 83 | scale: 3x 84 | filename: Icon-App-29x29@3x.png 85 | - size: 40x40 86 | scale: 1x 87 | filename: Icon-App-40x40@1x.png 88 | - size: 40x40 89 | scale: 2x 90 | filename: Icon-App-40x40@2x.png 91 | - size: 40x40 92 | scale: 3x 93 | filename: Icon-App-40x40@3x.png 94 | - size: 60x60 95 | scale: 1x 96 | filename: Icon-App-60x60@1x.png 97 | - size: 60x60 98 | scale: 2x 99 | filename: Icon-App-60x60@2x.png 100 | - size: 60x60 101 | scale: 3x 102 | filename: Icon-App-60x60@3x.png 103 | - size: 76x76 104 | scale: 1x 105 | filename: Icon-App-76x76@1x.png 106 | - size: 76x76 107 | scale: 2x 108 | filename: Icon-App-76x76@2x.png 109 | - size: 83.5x83.5 110 | scale: 2x 111 | filename: Icon-App-83.5x83.5@2x.png 112 | - size: 1024x1024 113 | scale: 1x 114 | filename: Icon-App-1024x1024@1x.png 115 | - name: macos 116 | path: macos/Runner/Assets.xcassets/AppIcon.appiconset/ 117 | images: 118 | - size: 16x16 119 | scale: 1x 120 | filename: app_icon_16.png 121 | - size: 32x32 122 | scale: 1x 123 | filename: app_icon_32.png 124 | - size: 64x64 125 | scale: 1x 126 | filename: app_icon_64.png 127 | - size: 128x128 128 | scale: 1x 129 | filename: app_icon_128.png 130 | - size: 256x256 131 | scale: 1x 132 | filename: app_icon_256.png 133 | - size: 512x512 134 | scale: 1x 135 | filename: app_icon_512.png 136 | - size: 1024x1024 137 | scale: 1x 138 | filename: app_icon_1024.png 139 | - name: web 140 | path: web/ 141 | images: 142 | - size: 16x16 143 | filename: favicon.png 144 | - size: 192x192 145 | path: icons/ 146 | filename: Icon-192.png 147 | - size: 512x512 148 | path: icons/ 149 | filename: Icon-512.png 150 | - size: 192x192 151 | path: icons/ 152 | filename: Icon-maskable-192.png 153 | - size: 512x512 154 | path: icons/ 155 | filename: Icon-maskable-512.png 156 | - name: windows 157 | path: windows/runner/resources/ 158 | images: 159 | - size: 256x256 160 | filename: app_icon.ico 161 | '''; 162 | --------------------------------------------------------------------------------