Skip to content

Commit

Permalink
feat: use blob for file builder
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanBorai committed May 25, 2023
1 parent 41c082c commit dd9309f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mince"
version = "0.0.5"
version = "0.0.6"
authors = ["Esteban Borai <estebanborai@gmail.com>"]
edition = "2021"

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# mince
Mince comes from "mincing" which means taking something that is roughly chopped and then chopping it finely

> **Warning** This package is under heavy development
## Development

1. Install `wasm-pack`
Expand Down
16 changes: 1 addition & 15 deletions src/image.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::io::BufWriter;
use std::io::Cursor;

use image::imageops::FilterType;
Expand Down Expand Up @@ -131,19 +130,6 @@ impl Mince {
Mince::new(dynamic_image, self.meta())
}

fn bytes(&self) -> Vec<u8> {
let bytes = Cursor::new(Vec::new());
let mut buf = BufWriter::new(bytes);
let format: ImageOutputFormat = self.meta.format.into();
self.inner.write_to(&mut buf, format).unwrap();

buf.buffer().to_vec()
}

fn uint8_array(&self) -> Uint8Array {
Uint8Array::from(self.bytes().as_slice())
}

pub fn write_blob(&self) -> Blob {
let mut options = BlobPropertyBag::new();
options.type_(self.meta.format.mime());
Expand All @@ -159,7 +145,7 @@ impl Mince {

pub fn write_file(&self) -> File {
let sequence = Array::new();
sequence.set(0, self.uint8_array().into());
sequence.set(0, self.write_blob().into());

let mut options = FilePropertyBag::new();

Expand Down

0 comments on commit dd9309f

Please sign in to comment.