Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Apple Pro Raw format (.DNG) #60

Merged
merged 6 commits into from
Mar 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions machine_learning/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
## CPU BUILD
FROM python:3.8 as cpu

RUN apt-get update
RUN apt-get install ffmpeg libsm6 libxext6 -y

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt
Expand Down
11 changes: 8 additions & 3 deletions machine_learning/app/image_classifier/image_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
from tensorflow.keras.applications.inception_v3 import preprocess_input, decode_predictions
from tensorflow.keras.preprocessing import image
import numpy as np

from PIL import Image
import cv2
IMG_SIZE = 299
PREDICTION_MODEL = InceptionV3(weights='imagenet')


def classify_image(image_path: str):
img_path = f'./app/{image_path}'
img = image.load_img(img_path, target_size=(IMG_SIZE, IMG_SIZE))
x = image.img_to_array(img)
# img = image.load_img(img_path, target_size=(IMG_SIZE, IMG_SIZE))

target_image = cv2.imread(img_path, cv2.IMREAD_UNCHANGED)
resized_target_image = cv2.resize(target_image, (IMG_SIZE, IMG_SIZE))

x = image.img_to_array(resized_target_image)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)

Expand Down
1 change: 1 addition & 0 deletions machine_learning/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
opencv-python==4.5.5.64
fastapi>=0.68.0,<0.69.0
pydantic>=1.8.0,<2.0.0
uvicorn>=0.15.0,<0.16.0
Expand Down
118 changes: 77 additions & 41 deletions mobile/lib/modules/home/ui/profile_drawer.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/modules/home/providers/asset.provider.dart';
import 'package:immich_mobile/modules/login/models/authentication_state.model.dart';
import 'package:immich_mobile/modules/login/providers/authentication.provider.dart';
import 'package:immich_mobile/shared/providers/backup.provider.dart';
import 'package:immich_mobile/shared/providers/websocket.provider.dart';
import 'package:package_info_plus/package_info_plus.dart';

class ProfileDrawer extends ConsumerWidget {
class ProfileDrawer extends HookConsumerWidget {
const ProfileDrawer({Key? key}) : super(key: key);

@override
Widget build(BuildContext context, WidgetRef ref) {
AuthenticationState _authState = ref.watch(authenticationProvider);
final appInfo = useState({});

_getPackageInfo() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();

appInfo.value = {
"version": packageInfo.version,
"buildNumber": packageInfo.buildNumber,
};
}

useEffect(() {
_getPackageInfo();

return null;
}, []);

return Drawer(
shape: const RoundedRectangleBorder(
Expand All @@ -21,50 +39,68 @@ class ProfileDrawer extends ConsumerWidget {
bottomRight: Radius.circular(5),
),
),
child: ListView(
padding: EdgeInsets.zero,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
DrawerHeader(
decoration: BoxDecoration(
color: Colors.grey[200],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Image(
image: AssetImage('assets/immich-logo-no-outline.png'),
width: 50,
filterQuality: FilterQuality.high,
ListView(
shrinkWrap: true,
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: BoxDecoration(
color: Colors.grey[200],
),
const Padding(padding: EdgeInsets.all(8)),
Text(
_authState.userEmail,
style: TextStyle(color: Theme.of(context).primaryColor, fontWeight: FontWeight.bold),
)
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Image(
image: AssetImage('assets/immich-logo-no-outline.png'),
width: 50,
filterQuality: FilterQuality.high,
),
const Padding(padding: EdgeInsets.all(8)),
Text(
_authState.userEmail,
style: TextStyle(color: Theme.of(context).primaryColor, fontWeight: FontWeight.bold),
)
],
),
),
ListTile(
tileColor: Colors.grey[100],
leading: const Icon(
Icons.logout_rounded,
color: Colors.black54,
),
title: const Text(
"Sign Out",
style: TextStyle(color: Colors.black54, fontSize: 14),
),
onTap: () async {
bool res = await ref.read(authenticationProvider.notifier).logout();

if (res) {
ref.watch(backupProvider.notifier).cancelBackup();
ref.watch(assetProvider.notifier).clearAllAsset();
ref.watch(websocketProvider.notifier).disconnect();
AutoRouter.of(context).popUntilRoot();
}
},
)
],
),
ListTile(
tileColor: Colors.grey[100],
leading: const Icon(
Icons.logout_rounded,
color: Colors.black54,
),
title: const Text(
"Sign Out",
style: TextStyle(color: Colors.black54, fontSize: 14),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Version V${appInfo.value["version"]}+${appInfo.value["buildNumber"]}",
style: TextStyle(
fontSize: 12,
color: Colors.grey[400],
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic,
),
),
onTap: () async {
bool res = await ref.read(authenticationProvider.notifier).logout();

if (res) {
ref.watch(backupProvider.notifier).cancelBackup();
ref.watch(assetProvider.notifier).clearAllAsset();
ref.watch(websocketProvider.notifier).disconnect();
AutoRouter.of(context).popUntilRoot();
}
},
)
],
),
Expand Down
3 changes: 3 additions & 0 deletions mobile/lib/utils/files_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class FileHelper {
case 'heif':
return {"type": "image", "subType": "heif"};

case 'dng':
return {"type": "image", "subType": "dng"};

default:
return {"type": "unsupport", "subType": "unsupport"};
}
Expand Down
42 changes: 42 additions & 0 deletions mobile/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,48 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
package_info_plus:
dependency: "direct main"
description:
name: package_info_plus
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.0"
package_info_plus_linux:
dependency: transitive
description:
name: package_info_plus_linux
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
package_info_plus_macos:
dependency: transitive
description:
name: package_info_plus_macos
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
package_info_plus_web:
dependency: transitive
description:
name: package_info_plus_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
package_info_plus_windows:
dependency: transitive
description:
name: package_info_plus_windows
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
path:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions mobile/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies:
# mapbox_gl: ^0.15.0
flutter_map: ^0.14.0
flutter_udid: ^2.0.0
package_info_plus: ^1.4.0

dev_dependencies:
flutter_test:
Expand Down
2 changes: 1 addition & 1 deletion server/src/config/multer-option.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const multerConfig = {

export const multerOption: MulterOptions = {
fileFilter: (req: Request, file: any, cb: any) => {
if (file.mimetype.match(/\/(jpg|jpeg|png|gif|mp4|x-msvideo|quicktime|heic|heif)$/)) {
if (file.mimetype.match(/\/(jpg|jpeg|png|gif|mp4|x-msvideo|quicktime|heic|heif|dng)$/)) {
cb(null, true);
} else {
cb(new HttpException(`Unsupported file type ${extname(file.originalname)}`, HttpStatus.BAD_REQUEST), false);
Expand Down
11 changes: 9 additions & 2 deletions server/src/modules/image-optimize/image-optimize.processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,19 @@ export class ImageOptimizeProcessor {
console.error('Error Reading File');
}

if (savedAsset.mimeType == 'image/heic' || savedAsset.mimeType == 'image/heif') {
// Special Assets Type - ios
if (
savedAsset.mimeType == 'image/heic' ||
savedAsset.mimeType == 'image/heif' ||
savedAsset.mimeType == 'image/dng'
) {
let desitnation = '';
if (savedAsset.mimeType == 'image/heic') {
desitnation = resizePath.replace('.HEIC', '.jpeg');
} else {
} else if (savedAsset.mimeType == 'image/heif') {
desitnation = resizePath.replace('.HEIF', '.jpeg');
} else if (savedAsset.mimeType == 'image/dng') {
desitnation = resizePath.replace('.DNG', '.jpeg');
}

sharp(data)
Expand Down