Skip to content

Commit

Permalink
fix: really resize the image
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekmedia committed Sep 26, 2024
1 parent 5caf46f commit eb1315d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';

import 'package:flutter_app_packager/src/api/app_package_maker.dart';
import 'package:flutter_app_packager/src/makers/appimage/make_appimage_config.dart';
import 'package:image/image.dart' as img;
import 'package:path/path.dart' as path;
import 'package:shell_executor/shell_executor.dart';

Expand Down Expand Up @@ -135,19 +136,23 @@ class AppPackageMakerAppImage extends AppPackageMaker {
}
});

await iconFile.copy(
path.join(
icon128x128,
'${makeConfig.appName}${path.extension(makeConfig.icon)}',
),
final icon128 = img.copyResize(
img.decodeImage(iconFile.readAsBytesSync())!,
width: 128,
height: 128,
);

await iconFile.copy(
path.join(
icon256x256,
'${makeConfig.appName}${path.extension(makeConfig.icon)}',
),
final icon128File =
File(path.join(icon128x128, '${makeConfig.appBinaryName}.png'));
await icon128File.writeAsBytes(img.encodePng(icon128));

final icon256 = img.copyResize(
img.decodeImage(iconFile.readAsBytesSync())!,
width: 128,
height: 128,
);
final icon256File =
File(path.join(icon256x256, '${makeConfig.appBinaryName}.png'));
await icon256File.writeAsBytes(img.encodePng(icon256));

if (makeConfig.metainfo != null) {
final metainfoDir = path.join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';

import 'package:flutter_app_packager/src/api/app_package_maker.dart';
import 'package:flutter_app_packager/src/makers/deb/make_deb_config.dart';
import 'package:image/image.dart' as img;
import 'package:path/path.dart' as path;
import 'package:shell_executor/shell_executor.dart';

Expand Down Expand Up @@ -77,18 +78,23 @@ class AppPackageMakerDeb extends AppPackageMaker {
throw MakeError("provided icon ${makeConfig.icon} path wasn't found");
}

await iconFile.copy(
path.join(
icon128Dir,
makeConfig.appBinaryName + path.extension(makeConfig.icon!),
),
final icon128 = img.copyResize(
img.decodeImage(iconFile.readAsBytesSync())!,
width: 128,
height: 128,
);
await iconFile.copy(
path.join(
icon256Dir,
makeConfig.appBinaryName + path.extension(makeConfig.icon!),
),
final icon128File =
File(path.join(icon128Dir, '${makeConfig.appBinaryName}.png'));
await icon128File.writeAsBytes(img.encodePng(icon128));

final icon256 = img.copyResize(
img.decodeImage(iconFile.readAsBytesSync())!,
width: 128,
height: 128,
);
final icon256File =
File(path.join(icon256Dir, '${makeConfig.appBinaryName}.png'));
await icon256File.writeAsBytes(img.encodePng(icon256));
}
if (makeConfig.metainfo != null) {
final metainfoPath =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';

import 'package:flutter_app_packager/src/api/app_package_maker.dart';
import 'package:flutter_app_packager/src/makers/pacman/make_pacman_config.dart';
import 'package:image/image.dart' as img;
import 'package:path/path.dart' as path;
import 'package:shell_executor/shell_executor.dart';

Expand Down Expand Up @@ -74,18 +75,23 @@ class AppPackageMakerPacman extends AppPackageMaker {
throw MakeError("provided icon ${makeConfig.icon} path wasn't found");
}

await iconFile.copy(
path.join(
icon128Dir,
makeConfig.appBinaryName + path.extension(makeConfig.icon!),
),
final icon128 = img.copyResize(
img.decodeImage(iconFile.readAsBytesSync())!,
width: 128,
height: 128,
);
await iconFile.copy(
path.join(
icon256Dir,
makeConfig.appBinaryName + path.extension(makeConfig.icon!),
),
final icon128File =
File(path.join(icon128Dir, '${makeConfig.appBinaryName}.png'));
await icon128File.writeAsBytes(img.encodePng(icon128));

final icon256 = img.copyResize(
img.decodeImage(iconFile.readAsBytesSync())!,
width: 128,
height: 128,
);
final icon256File =
File(path.join(icon256Dir, '${makeConfig.appBinaryName}.png'));
await icon256File.writeAsBytes(img.encodePng(icon256));
}
if (makeConfig.metainfo != null) {
final metainfoPath =
Expand Down
1 change: 1 addition & 0 deletions packages/flutter_app_packager/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ environment:

dependencies:
archive: ^3.6.1
image: ^4.2.0
io: ^1.0.3
liquid_engine: ^0.2.2
msix: ^3.16.6
Expand Down

0 comments on commit eb1315d

Please sign in to comment.