Skip to content

Commit

Permalink
edit-orientation: add some warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <radialapps@gmail.com>
  • Loading branch information
pulsejet committed Nov 2, 2023
1 parent e64d1e8 commit a7e7f80
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
24 changes: 18 additions & 6 deletions src/components/modal/EditMetadataModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { showWarning } from '@nextcloud/dialogs';
import NcButton from '@nextcloud/vue/dist/Components/NcButton';
const NcTextField = () => import('@nextcloud/vue/dist/Components/NcTextField');
const NcProgressBar = () => import('@nextcloud/vue/dist/Components/NcProgressBar');
Expand All @@ -74,7 +72,7 @@ import EditExif from './EditExif.vue';
import EditLocation from './EditLocation.vue';
import EditOrientation from './EditOrientation.vue';
import { showError } from '@nextcloud/dialogs';
import { showWarning, showError } from '@nextcloud/dialogs';
import axios from '@nextcloud/axios';
import * as dav from '@services/dav';
Expand Down Expand Up @@ -137,12 +135,26 @@ export default defineComponent({
// Filter out forbidden MIME types
photos = photos.filter((p) => {
if (this.c.FORBIDDEN_EDIT_MIMES.includes(p.mimetype ?? String())) {
showWarning(
this.t('memories', 'Cannot edit {name} of type {type}', { name: p.basename!, type: p.mimetype! }),
);
showError(this.t('memories', 'Cannot edit {name} of type {type}', { name: p.basename!, type: p.mimetype! }));
return false;
}
// Extra filters if orientation is in the sections
if (sections.includes(5)) {
// Videos might work but we don't want to risk it
if (p.mimetype?.startsWith('video/')) {
showError(this.t('memories', 'Cannot edit rotation on videos ({name})', { name: p.basename! }));
return false;
}
// Live photos cannot be edited because the orientation of the video
// will remain the same and look wrong.
if (p.liveid) {
showError(this.t('memories', 'Cannot edit rotation on Live Photos ({name})', { name: p.basename! }));
return false;
}
}
return true;
});
Expand Down
8 changes: 7 additions & 1 deletion src/components/modal/EditOrientation.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<template>
<div class="edit-orientation" v-if="samples.length">
{{
t(
'memories',
'This feature rotates images losslessly by updating the EXIF metadata. This approach is known to sometimes not work correctly on certain image types such as HEIC. Make sure you do a test run before using it on multiple images.',
)
}}

<div class="samples">
<XImg v-for="src of samples" class="sample" :key="src" :src="src" :style="{ transform }" />
<div class="sample more" v-if="photos.length > samples.length">
Expand Down Expand Up @@ -208,7 +215,6 @@ export default defineComponent({
<style scoped lang="scss">
.edit-orientation {
margin: 4px 0;
text-align: center;
.samples {
display: grid;
Expand Down

0 comments on commit a7e7f80

Please sign in to comment.