Skip to content

Commit

Permalink
updated so that the logging is on ERROR and also it spits out by defa…
Browse files Browse the repository at this point in the history
…ult a lot more info from the default script now
  • Loading branch information
James Campbell committed Oct 30, 2021
1 parent 51d8892 commit 9542c10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Binary file added fixtures/tagstest.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 14 additions & 4 deletions iptcinfo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import sys
import tempfile
from struct import pack, unpack
import json

__version__ = '2.1.4'
__author__ = 'Gulácsi, Tamás'
Expand Down Expand Up @@ -771,15 +772,15 @@ def jpegScan(self, fh):
# Now blindScan through the data.
return self.blindScan(fh, MAX=jpeg_get_variable_length(fh))

def blindScan(self, fh, MAX=8192):
def blindScan(self, fh, MAX=819200):
"""Scans blindly to first IIM Record 2 tag in the file. This
method may or may not work on any arbitrary file type, but it
doesn't hurt to check. We expect to see this tag within the first
8k of data. (This limit may need to be changed or eliminated
depending on how other programs choose to store IIM.)"""

offset = 0
# keep within first 8192 bytes
# keep within first 819200 bytes
# NOTE: this may need to change
logger.debug('blindScan: starting scan, max length %d', MAX)

Expand Down Expand Up @@ -956,7 +957,16 @@ def photoshopIIMBlock(self, otherparts, data):


if __name__ == '__main__': # pragma: no cover
logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.ERROR)
if len(sys.argv) > 1:
info = IPTCInfo(sys.argv[1])
print(info)
if info.__dict__ != '':
for k, v in info.__dict__.items():
if k == '_data':
print(k)
for key, value in v.items():
if type(value) == list:
print(key, [x.decode() for x in value])
[print(x.decode()) for x in value]
print(key, value)
print(k, v)

0 comments on commit 9542c10

Please sign in to comment.