Compare commits

..

3 Commits

Author SHA1 Message Date
itsjunetime 997631aac9 inline pnm decoder instead of using generalized load fn 2026-03-08 15:08:32 -05:00
June 725c6c6bfd Simpler tokio runtime (#140)
* Simpler tokio runtime; 3 threads and no io driver

* switch benches over to other runtime
2026-03-05 15:54:55 -06:00
June fca61d55b5 Remove tip workflow (#141) 2026-03-05 15:54:36 -06:00
3 changed files with 24 additions and 54 deletions
-37
View File
@@ -11,7 +11,6 @@ on:
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
tip_release_path: RELEASE.md
jobs: jobs:
test-build: test-build:
@@ -107,39 +106,3 @@ jobs:
generate_release_notes: true generate_release_notes: true
files: release-artifacts/* files: release-artifacts/*
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
tip-release:
name: Release tip on push to main
runs-on: ubuntu-slim
if: github.event_name == 'push' && github.ref_name == 'main'
needs: test-build
steps:
- uses: actions/checkout@v6
- name: Download prebuilt artifacts
uses: actions/download-artifact@v7
with:
path: release-artifacts
merge-multiple: true
- name: Generate release notes
run: |
tree release-artifacts/
echo "From commit: $(git rev-parse --short HEAD)" > ${{ env.tip_release_path }}
echo "Generated on: $(date -u +"%Y-%m-%d %H:%M") UTC" >> ${{ env.tip_release_path }}
cat ${{ env.tip_release_path }}
- name: Update the tip tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag --force tip && git push --force origin tag tip
- name: Update the draft tip release
uses: softprops/action-gh-release@v2
with:
prerelease: true
files: release-artifacts/*
tag_name: tip
name: Tip Build
body_path: ${{ env.tip_release_path }}
+18 -11
View File
@@ -1,11 +1,12 @@
use std::{ use std::{
io::Cursor,
num::NonZeroUsize, num::NonZeroUsize,
time::{SystemTime, UNIX_EPOCH} time::{SystemTime, UNIX_EPOCH}
}; };
use flume::{Receiver, SendError, Sender, TryRecvError}; use flume::{Receiver, SendError, Sender, TryRecvError};
use futures_util::stream::StreamExt as _; use futures_util::stream::StreamExt as _;
use image::DynamicImage; use image::{DynamicImage, codecs::pnm::PnmDecoder};
use kittage::{NumberOrId, action::NONZERO_ONE}; use kittage::{NumberOrId, action::NONZERO_ONE};
use ratatui::layout::Rect; use ratatui::layout::Rect;
use ratatui_image::{ use ratatui_image::{
@@ -111,22 +112,26 @@ pub async fn run_conversion_loop(
return Ok(None); return Ok(None);
}; };
let mut dyn_img = image::load_from_memory_with_format( let decoder = PnmDecoder::new(Cursor::new(&page_info.img_data.pixels)).map_err(|e| {
&page_info.img_data.pixels, RenderError::Converting(format!(
image::ImageFormat::Pnm "The image data provided from mupdf was not in pnm format ({e}); don't know how to convert"
) ))
.map_err(|e| RenderError::Converting(format!("Can't load image: {e}")))?; })?;
// The image we get should always already be `ImageRgb8`, so this `into` shouldn't do any
// conversions or anything, but just in case some underlying detail of mupdf or image
// changes, we do the `into` instead of just `match + unreachable!()` to avoid panicking
let mut dyn_img = DynamicImage::from_decoder(decoder)
.map_err(|e| RenderError::Converting(format!("Can't load image: {e}")))?
.into_rgb8();
match dyn_img {
DynamicImage::ImageRgb8(ref mut img) =>
for quad in &*page_info.result_rects { for quad in &*page_info.result_rects {
img.par_enumerate_pixels_mut() dyn_img
.par_enumerate_pixels_mut()
.filter(|(x, y, _)| { .filter(|(x, y, _)| {
*x > quad.ul_x && *x < quad.lr_x && *y > quad.ul_y && *y < quad.lr_y *x > quad.ul_x && *x < quad.lr_x && *y > quad.ul_y && *y < quad.lr_y
}) })
.for_each(|(_, _, px)| px.0[2] = px.0[2].saturating_sub(u8::MAX / 2)); .for_each(|(_, _, px)| px.0[2] = px.0[2].saturating_sub(u8::MAX / 2));
},
_ => unreachable!()
} }
let img_area = Rect { let img_area = Rect {
@@ -136,6 +141,8 @@ pub async fn run_conversion_loop(
y: 0 y: 0
}; };
let dyn_img = DynamicImage::ImageRgb8(dyn_img);
let txt_img = match picker.protocol_type() { let txt_img = match picker.protocol_type() {
ProtocolType::Kitty => { ProtocolType::Kitty => {
let rn = SystemTime::now() let rn = SystemTime::now()