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

extractThumbnail fails for images with special characters in the filename on Windows #124

Closed
jrast opened this issue Jan 2, 2023 · 3 comments

Comments

@jrast
Copy link

jrast commented Jan 2, 2023

It seems like extracting thumbnails from images with special characters in the name fails. I'm using the following code to extract the thumbnail from an image:

import { exiftool } from 'exiftool-vendored'
import * as path from 'path'

const file = './dummy_data/IMG_6176 - Cöpy.cr2'
const filePath = path.resolve(file)

async function extractThumbnail(file): Promise<void> {
  const outFile = file + '.thumbnail.jpg'
  console.log(`Extracting Thumbnail of ${file} -> ${outFile}`)
  return exiftool
    .extractThumbnail(file, file + '.thumbnail.jpg')
    .then(() => console.log('Thumbnail extracted'))
    .catch((error) => console.log('Thumbnail extraction failed:', error))
}

async function getExifTags(file): Promise<void> {
  return exiftool.read(file).then((tags) => {
    console.log(`Make: ${tags.Make}, Model: ${tags.Model}, Errors: ${tags.errors}`)
    console.log(`Description: ${tags.Description}`)
    console.log(`Keywords: ${tags.Keywords}`)
    console.log(`Rating: ${tags.Rating}`)
  })
}

async function main() {
  try {
    await getExifTags(filePath)
    await extractThumbnail(filePath)
  } finally {
    exiftool.end()
  }
}

main().then(() => console.log('Done!'))

And I'm getting the following Error:

Extracting Thumbnail of D:\Entwicklung\electron-vue-app\dummy_data\IMG_6176 - Cöpy.cr2 -> D:\Entwicklung\electron-vue-app\dummy_data\IMG_6176 - Cöpy.cr2.thumbnail.jpg
Thumbnail extraction failed: Error: File not found - D:/Entwicklung/electron-vue-app/dummy_data/IMG_6176 - Cöpy.cr2
    at BinaryExtractionTask.parser (D:\Entwicklung\electron-vue-app\node_modules\exiftool-vendored\src\ExifToolTask.ts:22:19)
    at BinaryExtractionTask._Task_resolve (D:\Entwicklung\electron-vue-app\node_modules\batch-cluster\src\Task.ts:144:38)

Note that reading the tags works as expected!

@mceachen mceachen changed the title extractThumbnail fails for images with special characters in the filename extractThumbnail fails for images with special characters in the filename on Windows Jan 5, 2023
mceachen added a commit that referenced this issue Jan 11, 2023
- add Utf8FilenameCharsetArgs to all read/write args
- extract a couple types and methods into their own file to break dependency loops
- add a suite of non-alphanumeric filename tests for all read/write tasks
- rebuild docs
@mceachen
Copy link
Member

Bugfixes and tests are in new v19.0.0. Thanks for the bug report!

@jrast
Copy link
Author

jrast commented Jan 12, 2023

Thank you for the quick fix! I will try the new version!

@bheston
Copy link

bheston commented Feb 12, 2023

Thanks for this! I was about to make a similar fix for another issue I don't see mentioned, which is that every write action that has been done before this was fixed introduced a mostly empty IPTC section. This is because CodedCharacterSet was specified which is an actual tag that exiftool is being told to set, not a modifier or configuration option like the others.

So now to go remove the IPTC section from all the files I've written in the past... 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants