Skip to content

Commit

Permalink
Comments out the heic support, and removes heic2any as a dependency. …
Browse files Browse the repository at this point in the history
  • Loading branch information
KenEucker committed Nov 15, 2023
1 parent bf0e657 commit f237689
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 43 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"crypto-js": "^4.1.1",
"dom-to-image": "^2.6.0",
"exifr": "^7.1.3",
"heic2any": "^0.0.4",
"jose": "^4.6.0",
"liquidjs": "^9.34.0",
"loglevel": "^1.8.0",
Expand Down
44 changes: 23 additions & 21 deletions src/components/QueueFound.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
ref="file"
type="file"
class="d-none"
accept="image/*,.heic,.heif"
accept="image/*"
required
@change="setImage"
/>
Expand Down Expand Up @@ -135,7 +135,7 @@ import { debug, isPointInPolygon, isAuthenticationEnabled } from '@/common/utils
import { useI18n } from 'vue-i18n'
import exifr from 'exifr'
import Pin from '@/assets/images/pin.svg'
import heic2any from 'heic2any';
// import heic2any from 'heic2any';
// components
import Loading from 'vue-loading-overlay'
Expand Down Expand Up @@ -354,27 +354,29 @@ const setImage = async (event) => {
position: 'top',
})
} else {
const imageFile = input.files[0];
// const imageFile = input.files[0];
image.value = input.files[0];
// Check if the file type is HEIC
if (imageFile.type === 'image/heic' || imageFile.name.toLowerCase().endsWith('.heic')) {
try {
const pngBlob = await heic2any({ blob: imageFile });
const pngFile = new File([pngBlob], 'converted.png', { type: 'image/png' });
image.value = pngFile;
} catch (conversionError) {
console.error('Error converting HEIC to PNG:', conversionError);
toast.open({
message: 'Error converting HEIC to PNG',
type: 'error',
position: 'top',
});
return;
}
} else {
// For non-HEIC files, proceed with the original image
image.value = imageFile;
}
// TODO: this needs resolved: https://github.com/alexcorvi/heic2any/issues/53
// if (imageFile.type === 'image/heic' || imageFile.name.toLowerCase().endsWith('.heic')) {
// try {
// const pngBlob = await heic2any({ blob: imageFile });
// const pngFile = new File([pngBlob], 'converted.png', { type: 'image/png' });
// image.value = pngFile;
// } catch (conversionError) {
// console.error('Error converting HEIC to PNG:', conversionError);
// toast.open({
// message: 'Error converting HEIC to PNG',
// type: 'error',
// position: 'top',
// });
// return;
// }
// } else {
// // For non-HEIC files, proceed with the original image
// image.value = imageFile;
// }
const results = await exifr.parse(await input.files[0].arrayBuffer());
const createDate = results?.CreateDate ?? results?.DateTimeOriginal ?? Date.now();
Expand Down
43 changes: 22 additions & 21 deletions src/components/QueueMystery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ import { useStore } from '@/store/index'
import { ordinalSuffixOf } from '@/common/utils'
import exifr from 'exifr'
import { useI18n } from 'vue-i18n'
import heic2any from 'heic2any';
// import heic2any from 'heic2any';
// components
import BikeTagButton from '@/components/BikeTagButton.vue'
Expand Down Expand Up @@ -203,27 +203,28 @@ const setImage = async (event) => {
position: 'top',
})
} else {
const imageFile = input.files[0];
// const imageFile = input.files[0];
image.value = input.files[0];
// Check if the file type is HEIC
if (imageFile.type === 'image/heic' || imageFile.name.toLowerCase().endsWith('.heic')) {
try {
const pngBlob = await heic2any({ blob: imageFile });
const pngFile = new File([pngBlob], 'converted.png', { type: 'image/png' });
image.value = pngFile;
} catch (conversionError) {
console.error('Error converting HEIC to PNG:', conversionError);
toast.open({
message: 'Error converting HEIC to PNG',
type: 'error',
position: 'top',
});
return;
}
} else {
// For non-HEIC files, proceed with the original image
image.value = imageFile;
}
// // Check if the file type is HEIC
// if (imageFile.type === 'image/heic' || imageFile.name.toLowerCase().endsWith('.heic')) {
// try {
// const pngBlob = await heic2any({ blob: imageFile });
// const pngFile = new File([pngBlob], 'converted.png', { type: 'image/png' });
// image.value = pngFile;
// } catch (conversionError) {
// console.error('Error converting HEIC to PNG:', conversionError);
// toast.open({
// message: 'Error converting HEIC to PNG',
// type: 'error',
// position: 'top',
// });
// return;
// }
// } else {
// // For non-HEIC files, proceed with the original image
// image.value = imageFile;
// }
const results = await exifr.parse(await input.files[0].arrayBuffer());
const createDate = results?.CreateDate ?? results?.DateTimeOriginal ?? Date.now();
Expand Down

0 comments on commit f237689

Please sign in to comment.