Skip to content

Commit

Permalink
tmp changed to work on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Benes committed Jan 29, 2024
1 parent e6e4bd4 commit a124f82
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/jpeglib/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import numpy as np
import os
import tempfile
import typing

Expand Down Expand Up @@ -469,8 +470,11 @@ def qf_to_qt(
0, 256, (16, 16, in_color_space.channels),
dtype='uint8',
)
with tempfile.NamedTemporaryFile(suffix='.jpeg') as tmp:
from_spatial(x, in_color_space=in_color_space).write_spatial(tmp.name)

# collect quantization table
return read_dct(tmp.name).qt
tmp = tempfile.NamedTemporaryFile('w', suffix='.jpeg', delete=False)
tmp.close()
from_spatial(x, in_color_space=in_color_space).write_spatial(tmp.name)

# collect quantization table
qt = read_dct(tmp.name).qt
os.unlink(tmp.name)
return qt

0 comments on commit a124f82

Please sign in to comment.