Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/imcflibs/imagej/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,3 +711,23 @@
IJ.log("Conversion to .ims is finished.")
else:
IJ.log("Conversion failed with error code: %d" % result)

def convert_bytes(size):
"""Convert size from bytes to a readable value.

Parameters
----------
size : int
Byte size

Returns
-------
str
Easy to read value with the correct unit
"""
for x in ["bytes", "KB", "MB", "GB", "TB"]:
if size < 1024.0:
return "%3.1f %s" % (size, x)
size /= 1024.0

Check warning on line 731 in src/imcflibs/imagej/misc.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/misc.py#L728-L731

Added lines #L728 - L731 were not covered by tests

return size

Check warning on line 733 in src/imcflibs/imagej/misc.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/misc.py#L733

Added line #L733 was not covered by tests
Loading