Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 10 00:42
    fintelia commented #1748
  • Aug 03 02:39
    fintelia transferred #1768
  • Aug 02 23:50
    BlueSwordM edited #1768
  • Aug 02 23:49
    BlueSwordM opened #1768
  • Jul 30 11:56
    simonrepp opened #1767
  • Jul 29 00:29
    AstroFloof closed #1766
  • Jul 29 00:29
    AstroFloof commented #1766
  • Jul 29 00:04
    fintelia commented #1766
  • Jul 27 20:03
    AstroFloof opened #1766
  • Jul 27 19:28
    HeroicKatora labeled #1765
  • Jul 27 16:56
    sorairolake edited #1765
  • Jul 27 15:15
    sorairolake opened #1765
  • Jul 25 18:59
    fintelia commented #1764
  • Jul 25 17:18
    AngelicosPhosphoros opened #1764
  • Jul 24 17:58
    fintelia commented #1760
  • Jul 24 17:56
    fintelia commented #1760
  • Jul 24 17:20

    fintelia on master

    Clone instead of resize when im… two fixes Run cargo fmt and 6 more (compare)

  • Jul 24 17:20
    fintelia closed #1763
  • Jul 24 10:17
    WilliamVenner commented #1671
  • Jul 24 06:07
    drewcassidy synchronize #1763
A. Bos
@adhesivee
When loading an vertical JPG, it gets rotated after image::open.
Is there a way to prevent this from happening?
HeroicKatora
@heroic_katora:matrix.org
[m]
We just load the pixel matrix, an image's orientation is usually stored as an attribute separate from it.
For accessing such meta data you'll need to use the jpeg decoder direct (as in, the crate)
A. Bos
@adhesivee
Thanks found it. Working like a charm now
Marco Köpcke
@theCapypara
Hi everyone! I am a bit lost on using this library for my use case, and I'm not sure it's even supported: How do I create indexed images that use color palettes ("P" mode in PIL)?
And if it's not supported is there no library that supports it? I can't seem to find any other either.
pyfisch
@pyfisch:matrix.org
[m]
Is there a recommended command line fronted for image? Akin to imagemagick?
HeroicKatora
@heroic_katora:matrix.org
[m]
In addition you might want to take a look at imageflow whic implements the standard restful image API over http (but doesn't use the main image crate underneath afaik): https://github.com/imazen/imageflow
HeroicKatora
@heroic_katora:matrix.org
[m]
I mistyped restful as rustful, freudian slip ^^
CarlyRaeJepsenStan
@CarlyRaeJepsenStan
Hey guys, is there a way to make my grayscale image (a list of Lumas) into a vector of just numbers?
HeroicKatora
@heroic_katora:matrix.org
[m]
I'm not sure I understand. Do you mean the grayscale values?
If so then the ImageBuffer will dereference into a slice of the values you seek
paolobarbolini
@paolobarbolini:matrix.org
[m]
Hello, is a release of jpeg-decoder planned for the following weeks?
HeroicKatora
@heroic_katora:matrix.org
[m]
Yes, sometimes soon, most often on start of weekend. I just didn't have the time this one.
Including SIMD code is also going to be a bit exciting, let's hope in good way.
Arif Driessen
@arifd

Hi guys, I want to mutate the pixels of a SubImage. The sub_image() method tells me that it gets a mutable slice to the image.
but i can't call pixels_mut() or iter_mut() or anything like that on it.

My current solution is so forth:

let mut sub_image = page_image.sub_image(x, y, w, h);
// copy sub_image so that we don't borrow mut above, and borrow (no mut) below
let sub_image_pixels = sub_image.pixels().collect::<Vec<_>>();
sub_image_pixels.iter().for_each(|(x, y, pixel)| {
    // do something with the `pixel`
    sub_image.put_pixel(*x, *y, new_value)
});

but I want something more like:

page_image
    .sub_image(x, y, w, h)
    .pixels_mut()
    .for_each(|(x, y, pixel)| {
        // do something with the `pixel` value
        *pixel = new_value;
    });

Any suggestion? Thanks in advance!

2 replies
HeroicKatora
@heroic_katora:matrix.org
[m]

Probably external iteration over the region with one or two loops. It pains me everytime a little bit when I say that but that's it.
Sometimes in the future Rust will make it possible to write a 2d-equivalent of Iterators and then this changes.

For the moment, have a look at the implementation of some blending in image itself:
https://docs.rs/image/latest/src/image/imageops/mod.rs.html#215-236

Arif Driessen
@arifd
👍
frankenapps
@frankenapps:matrix.org
[m]
Hi, what is the best way to convert from an ImageBuffer::<Rgba<u8>, _> to an ImageBuffer::<Rgb<u8>, _>? Is there any built in functionality?
Thanks in advance
4 replies
Lyssieth
@lyssieth

Hi! When upgrading from image v0.23.14 -> v0.24.1, the write_to function now requires Seek.
My current usage of it breaks, as I was using it to write to a Vec<u8> in a specific format to ensure all images are png formatted, even if the input is jpeg or some other format.

// The current implementation
// I'm downloading an unknown format of image, and if it isn't Png i'm converting it to Png with this bit of code,
// `data` is the unknown image, and `buf` is my intermediary buffer (Vec<u8>) for future tasks,
// aka running the image through oxipng's `optimize_from_memory`
let img = load_from_memory(&data)?;
img.write_to(&mut buf, ImageOutputFormat::Png)?;

The only workaround I could think of is saving to /tmp under a random name and then reading that back, but that feels unpleasant

4 replies
522
@r522:matrix.org
[m]

Could/should this room be added to the (unofficial but popular) rust matrix space? #rust-space:matrix.org is the space, but I don't know what the process is to get a room added, presumably just DM an admin?

partly because i think it would bring more visibility to this room

(and partly because i keep losing this room because I expect it to be in there)

1 reply
HeroicKatora
@heroic_katora:matrix.org
[m]
Not a bad idea, I'll DM them
EVLRBT-01
@EVLRBT-01
gm! Just wanted to ask about the best way to split an image up into blocks/tiles so that I can iterate over the pixels in said block: image decoder, buffer, subimage or slices of the main image pixels?
1 reply
HeroicKatora
@heroic_katora:matrix.org
[m]
This only works for a view, not for mutable images, because there's no way to safely write a generic mutable equivalent of the Pixels iterator at the moment.
EVLRBT-01
@EVLRBT-01
Amazing, thank you very much!
Chris Boyce
@chrisboyce

I'm trying to get a subimage and get access to the raw pixel data, similar to into_rgba8().as_raw(), but when I try to call to_image on my SubImage I get

the method to_image exists for struct SubImage<DynamicImage>, but its trait bounds were not satisfied
55 | pub enum DynamicImage {
| --------------------- doesn't satisfy DynamicImage: Deref

2 replies
The usage of to_image I'm finding online is called directly on the SubImage so I'm not sure what I'm missing
HeroicKatora
@heroic_katora:matrix.org
[m]
Hm, that's an interesting problem. Previously, SubImage was somewhat hidden and you'd only be expected to get a value by calling either GenericImage::sub_image or GenericImageView::view. Both of these correspond got a reference type parameter. But I can't say it's totally wrong to pass an owned image either.
As library designer I'd really like that to just work as well
Danilo
@dbrgn:matrix.coredump.ch
[m]
I'm resizing JPEG images with image-rs. However, right now the EXIF data is lost. Is there a way to easily retain it (read/write without modifications)?
HeroicKatora
@heroic_katora:matrix.org
[m]
Not through image for now. If you're using jpeg-decoder directly then you can grab exif and icc data for re-encoding
Danilo
@dbrgn:matrix.coredump.ch
[m]
HeroicKatora: Can jpeg-decoder write EXIF as well? I found a few EXIF related libs, but usually they only support either reading or writing.
HeroicKatora
@heroic_katora:matrix.org
[m]
Only decoding, so no. Did you try jpeg-encoder? It's a special app-segment, you should be able to write it.
We're not doing any exif-decoding anyways. The library gives you the exact bytes to write later, iirc.
Danilo
@dbrgn:matrix.coredump.ch
[m]
thanks!
1 reply
Danilo
@dbrgn:matrix.coredump.ch
[m]
HeroicKatora: I won't work in it today, but maybe next week 🙂
jpeg_decoder allows reading the raw exif data as bytes: https://docs.rs/jpeg-decoder/latest/jpeg_decoder/struct.Decoder.html#method.exif_data
You're saying I should use add_app_segment in jpeg_encoder?
HeroicKatora
@heroic_katora:matrix.org
[m]
I believe so. segment_nr should be 1 and the raw bytes preceed with the bytes: b"Exif\x00\x00"
Franfran
@iFrostizz
Hey, I'm trying to resize images using the image crate.
I would like to be able to do it both from an image URL or from a base64 image, but I don't know how to obtain this GenericImage type. Do anybody knows how to proceed please ?
1 reply
Daniel Bearden
@dbearden
Hi all,
I am generally curious about the lack of webp encoding support. Are there technical limitations or a lack of dev effort on this front?
I'm not advocating for the addition, simply wanting to educate myself, so any reading I can be pointed toward would be great :)
HeroicKatora
@heroic_katora:matrix.org
[m]
There's several bindings to libwebp-sys as a C library, which introduces some limitations with regards to integration, but mostly it's dev effort writing bindings, checking if it works on all targets to warrant enabling by default and such
The public interface of codecs::webp is rather small by design, should be easy to replace it with another decoder in the background if stability/features speak for such a move.
I'd be decently glad, it's been easier to maintain such things as separate crates.
lqdev
@lqdev:gacko.pl
[m]
hey, would this be the right place to ask about image-rs/image-gif? i couldn't find if it has its own channel
i have this weird issue where gifs produced by image-gif cannot be decoded by chromium-based browsers
lqdev
@lqdev:gacko.pl
[m]
alright i see what the problem is, i forgot to set the width and height of the frame
HeroicKatora
@heroic_katora:matrix.org
[m]
Still sounds like it should be better if it complained before writing the image!
Can you open a bug about it?
lqdev
@lqdev:gacko.pl
[m]
yup
lqdev
@lqdev:gacko.pl
[m]
this was quite a small thing so i made a PR image-rs/image-gif#135
HeroicKatora
@heroic_katora:matrix.org
[m]
Nice, thanks for immediately going for a fix and not only an opened issue 😁
marsmute
@TuckerBMorgan
I am working on a Sprite Sheet generator, currently I am reading my PNGs into memory, and then concatenating them together as a bunch of DynamicImages and then writing out the ImageBuffer as a PNG. At somepoint in that process the PNG stops being indexed color, is there a way to tell it tell image to preserve that information?
1 reply