Getting binary information with PyExifTool

Started by lolliffe, July 10, 2017, 06:30:21 PM

Previous topic - Next topic

lolliffe

I hope this isn't outside the scope of the forum, but I'll try.

In python, with exiftool installed, I can pull an MP3's binary image out, calling subprocess, e.g.

`proc = subprocess.Popen(['exiftool', '-Picture', '-b', sys.argv[1]],
                         stdout=subprocess.PIPE)
output = proc.stdout.read()
with open('out_pic.jpg', 'wb') as out_file:
    out_file.write(output)`
...and with PyExifTool installed, I can pull metadata, e.g.

`with exiftool.ExifTool() as et:
    make = et.get_metadata(sys.argv[1])['ID3:Artist']
    print(make)`
I could, but would rather not, use the subprocess way, of pulling the image, if I can do it with PyExifTool. But I haven't had any luck with something like:

`binary_string = et.execute('-Picture', '-b', sys.argv[1])`
or other variations, including when it erred out, telling me that the arguments needed to be byte strings, and trying things like  et.execute(byte('-Picture', 'utf-8'),..., where it stopped complaining, but gave me the result of b''.

If anyone has some guidance, especially if you've done this before, I'd appreciate the help.

Thanks in advance!

https://stackoverflow.com/questions/44940062/python-getting-binary-data-with-pyexiftool

lolliffe

P.S.  Mods, if this needs to be moved to a more appropriate section, please feel free.

Thanks

Phil Harvey

I am guessing that PyExifTool will run a sub-process anyway, so I would think that the first way you did it should be fine.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).