ExifTool Forum

ExifTool => Developers => Topic started by: Jean-Michel on November 13, 2024, 02:11:03 PM

Title: exiftool command line doesn't work when calld from python
Post by: Jean-Michel on November 13, 2024, 02:11:03 PM
Hello

I'm trying to call exiftool from a python code
The command line I want to execute is
exiftool -if '$jpgfromraw' -b -jpgfromraw -w %d%f.jpg -execute -if '$previewimage' -b -previewimage -w %d%f.jpg -execute -tagsfromfile @ -srcfile %d%f.jpg -overwrite_original -common_args --ext jpg test1.dng

The command works well from the shell:
$ exiftool -if '$jpgfromraw' -b -jpgfromraw -w %d%f.jpg -execute -if '$previewimage' -b -previewimage -w %d%f.jpg -execute -tagsfromfile @ -srcfile %d%f.jpg -overwrite_original -common_args --ext jpg test1.dng
    1 files failed condition
    0 output files created
Warning: [Minor] Not decoding some large array(s). Ignore minor errors to decode - test1.dng
    1 output files created
Warning: [Minor] Not decoding some large array(s). Ignore minor errors to decode - test1.dng
    1 image files updated

The test1.jpg is created, metadata are attached as expected

But it fails when called from a simple python code:
import os

os.system("exiftool -if '$jpgfromraw' -b -jpgfromraw -w %d%f.jpg -execute -if '$previewimage' -b -previewimage -w %d%f.jpg -execute -tagsfromfile @ -srcfile %d%f.jpg -overwrite_original -common_args --ext jpg test1.dng")

Resulting execution is:
$ python _test.py
    1 files failed condition
    0 output files created
    1 files failed condition
    0 output files created
Warning: [Minor] Not decoding some large array(s). Ignore minor errors to decode - test1.dng
Error: File not found - test1.jpg
    0 image files updated
    1 files weren't updated due to errors

It looks like at some point exiftool is not able to write the JPG

I have tried using `os.system()` as well as `subprocess.run()` without any success

Is there a way to get more debug or any hints ?
Title: Re: exiftool command line doesn't work when calld from python
Post by: StarGeek on November 13, 2024, 03:24:53 PM
Simplify the exiftool command down to just one step and see if that works.

Is python replacing anything in the code (I don't know enough about Python variables)? For example, is it replacing the tag names with the leading dollar sign with Python variables?
Title: Re: exiftool command line doesn't work when calld from python
Post by: Phil Harvey on November 13, 2024, 03:34:45 PM
I think StarGeek is likely correct (good catch!).  This would cause the exact output you are seeing.

- Phil