Skip to content

Commit

Permalink
Autodetect endianness on export
Browse files Browse the repository at this point in the history
  • Loading branch information
albfan committed Nov 3, 2024
1 parent 3c9d6ae commit 743198e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions raviewer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import logging
from .src.core import (get_displayable, load_image, parse_image)
from .src.utils import save_image_as_file
from .image.color_format import AVAILABLE_FORMATS
from .image.color_format import AVAILABLE_FORMATS, Endianness
from .gui.gui_init import AppInit
from .format_recognition.detect import classify_top1, predict_resolution
from .format_recognition.detect import classify_top1, classify_all, predict_resolution
from tests import test_formats


Expand Down Expand Up @@ -66,7 +66,8 @@ def run(file_path, width, height, color_format, export, args):
color_format, _ = classify_top1(img)
if width == 0:
width, _ = predict_resolution(img, color_format)[0]
img = parse_image(img.data_buffer, color_format, width)
predictions, endianness = classify_all(img)
img = parse_image(img.data_buffer, color_format, width, Endianness[endianness].value)
if height < 1: height = img.height
save_image_as_file(get_displayable(img, height), export)

Expand Down

0 comments on commit 743198e

Please sign in to comment.