Fix reading image index not working on older ImageMagick

Fixes #3384
This commit is contained in:
Kovid Goyal 2021-03-12 12:00:44 +05:30
parent 18186da90e
commit 271c39cc9d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -202,7 +202,7 @@ def render_image(
# we have to coalesce, resize and de-coalesce all frames # we have to coalesce, resize and de-coalesce all frames
resize_cmd = ['-coalesce'] + resize_cmd + ['-deconstruct'] resize_cmd = ['-coalesce'] + resize_cmd + ['-deconstruct']
cmd += resize_cmd cmd += resize_cmd
cmd += ['-depth', '8', '-set', 'filename:f', '%w-%h-%g'] cmd += ['-depth', '8', '-set', 'filename:f', '%w-%h-%g-%p']
ans = RenderedImage(m.fmt, width, height, m.mode) ans = RenderedImage(m.fmt, width, height, m.mode)
if only_first_frame: if only_first_frame:
ans.frames = [Frame(m.frames[0])] ans.frames = [Frame(m.frames[0])]
@ -228,7 +228,7 @@ def render_image(
ans.width = frame.width ans.width = frame.width
with tempfile.TemporaryDirectory(dir=os.path.dirname(output_prefix)) as tdir: with tempfile.TemporaryDirectory(dir=os.path.dirname(output_prefix)) as tdir:
output_template = os.path.join(tdir, f'im-%[filename:f]-%d.{m.mode}') output_template = os.path.join(tdir, f'im-%[filename:f].{m.mode}')
if get_multiple_frames: if get_multiple_frames:
cmd.append('+adjoin') cmd.append('+adjoin')
run_imagemagick(path, cmd + [output_template]) run_imagemagick(path, cmd + [output_template])