diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 99fbfdf..0d2475a 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -8,12 +8,21 @@ lane :ios do ) end +lane :ios_iphone do + appicon( + appicon_image_file: 'spec/fixtures/ThemojiSmall.png', + appicon_devices: %i[iphone], + appicon_path: 'app' + ) +end + lane :ios_splash do appicon( appicon_image_file: 'spec/fixtures/ThemojiSplash.png', appicon_devices: [:universal], appicon_path: 'app', - appicon_name: 'Splash.imageset' + appicon_name: 'Splash.imageset', + allow_upsampling: true ) end @@ -39,7 +48,8 @@ lane :android do android_appicon( appicon_image_file: 'spec/fixtures/Themoji.png', appicon_path: 'app/res/mipmap', - generate_rounded: true + generate_rounded: true, + allow_upsampling: true ) end diff --git a/lib/fastlane/plugin/appicon/actions/android_appicon_action.rb b/lib/fastlane/plugin/appicon/actions/android_appicon_action.rb index 0893965..c795254 100644 --- a/lib/fastlane/plugin/appicon/actions/android_appicon_action.rb +++ b/lib/fastlane/plugin/appicon/actions/android_appicon_action.rb @@ -49,11 +49,19 @@ def self.run(params) custom_sizes = params[:appicon_custom_sizes] icons = Helper::AppiconHelper.get_needed_icons(params[:appicon_icon_types], self.needed_icons, true, custom_sizes) + + allow_upsampling = params[:allow_upsampling] + if !allow_upsampling + input_image = MiniMagick::Image.open(fname) + # Check that the input image is large enough for the needed icons without upsampling + maxWidth = icons.map { |v| v['width'] }.max.to_i + maxHeight = icons.map { |v| v['height'] }.max.to_i + Helper::AppiconHelper.check_input_image_size(input_image, maxWidth, maxHeight) + end + icons.each do |icon| image = MiniMagick::Image.open(fname) - Helper::AppiconHelper.check_input_image_size(image, 1024, 1024) - # Custom icons will have basepath and filename already defined if icon.has_key?('basepath') && icon.has_key?('filename') basepath = Pathname.new(icon['basepath']) @@ -173,6 +181,12 @@ def self.available_options description: "Generate round icons?", default_value: false, type: Boolean), + FastlaneCore::ConfigItem.new(key: :allow_upsampling, + env_name: "ALLOW_UPSAMPLING", + default_value: false, + description: "Allow the input image to be upsampled to larger sizes", + optional: true, + type: Boolean), FastlaneCore::ConfigItem.new(key: :minimagick_cli, env_name: "APPICON_MINIMAGICK_CLI", description: "Set MiniMagick CLI (auto picked by default). Values are: graphicsmagick, imagemagick", diff --git a/lib/fastlane/plugin/appicon/actions/appicon_action.rb b/lib/fastlane/plugin/appicon/actions/appicon_action.rb index 2ea7134..cfc982d 100644 --- a/lib/fastlane/plugin/appicon/actions/appicon_action.rb +++ b/lib/fastlane/plugin/appicon/actions/appicon_action.rb @@ -75,13 +75,7 @@ def self.run(params) basepath = Pathname.new(File.join(params[:appicon_path], is_messages_extension ? params[:appicon_messages_name] : params[:appicon_name])) image = MiniMagick::Image.open(fname) - - if is_messages_extension - Helper::AppiconHelper.check_input_image_size(image, 1024, 768) - else - Helper::AppiconHelper.check_input_image_size(image, 1024, 1024) - end - + # Convert image to png image.format 'png' @@ -97,6 +91,15 @@ def self.run(params) images = [] icons = Helper::AppiconHelper.get_needed_icons(params[:appicon_devices], is_messages_extension ? self.needed_icons_messages_extension : self.needed_icons, false) + + allow_upsampling = params[:allow_upsampling] + if !allow_upsampling + # Check that the input image is large enough for the needed icons without upsampling + maxWidth = icons.map { |v| v['width'] }.max.to_i + maxHeight = icons.map { |v| v['height'] }.max.to_i + Helper::AppiconHelper.check_input_image_size(image, maxWidth, maxHeight) + end + icons.each do |icon| width = icon['width'] height = icon['height'] @@ -208,6 +211,12 @@ def self.available_options description: "App icon is generated for Messages extension", optional: true, type: Boolean), + FastlaneCore::ConfigItem.new(key: :allow_upsampling, + env_name: "ALLOW_UPSAMPLING", + default_value: false, + description: "Allow the input image to be upsampled to larger sizes", + optional: true, + type: Boolean), FastlaneCore::ConfigItem.new(key: :minimagick_cli, env_name: "APPICON_MINIMAGICK_CLI", description: "Set MiniMagick CLI (auto picked by default). Values are: graphicsmagick, imagemagick", diff --git a/spec/fixtures/ThemojiSmall.png b/spec/fixtures/ThemojiSmall.png new file mode 100644 index 0000000..b57d432 Binary files /dev/null and b/spec/fixtures/ThemojiSmall.png differ