Skip to content

Commit 53644ce

Browse files
wingedclaudep
authored andcommitted
fix performance in convert engine: exif orientation
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).
1 parent a2c7e57 commit 53644ce

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sorl/thumbnail/engines/convert_engine.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ def is_valid_image(self, raw_data):
110110

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

0 commit comments

Comments
 (0)