Skip to content

Commit

Permalink
fix performance in convert engine: exif orientation
Browse files Browse the repository at this point in the history
In other calls to the ImageMagick commandline tools, the suffix "[0]"
is added so it only looks at the first page if it's a multi-page document
such as a PDF.

For some reason, this is missing in the `_get_exif_orientation()` method,
and may cause very long runtimes when dealing with large documents (several hundred
pages of PDF).
  • Loading branch information
winged authored and claudep committed Nov 21, 2024
1 parent a2c7e57 commit 53644ce
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sorl/thumbnail/engines/convert_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def is_valid_image(self, raw_data):

def _get_exif_orientation(self, image):
args = settings.THUMBNAIL_IDENTIFY.split()
args.extend(['-format', '%[exif:orientation]', image['source']])
image_param = f"{image['source']}[0]"
args.extend(["-format", "%[exif:orientation]", image_param])
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.wait()
result = p.stdout.read().strip()
Expand Down

0 comments on commit 53644ce

Please sign in to comment.