Skip to content
Merged
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
10 changes: 9 additions & 1 deletion textual_image/widget/sixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def render_lines(self, crop: Region) -> list[Strip]:
image_data = self._scale_image(image_data, terminal_sizes)
image_data = self._crop_image(image_data, crop, terminal_sizes)

sixel_data = image_to_sixels(image_data.pil_image, self._sixel_options, background=background)
sixel_data = self._image_to_sixels(image_data.pil_image, self._sixel_options, background=background)
self._cached_sixels = _CachedSixels(
self.image, crop, self.content_size, terminal_sizes, self._sixel_options, background, sixel_data
)
Expand All @@ -193,6 +193,14 @@ def render_lines(self, crop: Region) -> list[Strip]:
lines = [Strip([])] * (crop.height - 1) + [Strip(sixel_segments, cell_length=crop.width)]
return lines

def _image_to_sixels(
self,
image: PILImage.Image,
sixel_options: SixelOptions | None = None,
background: BackgroundColor | None = None,
) -> str:
return image_to_sixels(image, sixel_options, background)

def _scale_image(self, image_data: PixelData, terminal_sizes: CellSize) -> PixelData:
assert isinstance(self.parent, Image)

Expand Down
Loading