Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Philip Molares
    @DerMolly
    I thought since resize, resize_img_browser and my own resize_img_node would share so much code it would be only logical to extract that code in an extra function.
    #[cfg(target_arch = "wasm32")]
    #[wasm_bindgen]
    pub fn resize_img_node(
        photon_img: &mut PhotonImage,
        width: u32,
        height: u32,
        sampling_filter: SamplingFilter,
    ) {
        println!("called resize_img_node");
        let resized_img = resize_internal(photon_img, width, height, sampling_filter);
    
        photon_img.raw_pixels = resized_img.raw_pixels()
    }
    
    /// Resize an image.
    ///
    /// # Arguments
    /// * `img` - A PhotonImage.
    /// * `width` - New width.
    /// * `height` - New height.
    /// * `sampling_filter` - Nearest = 1, Triangle = 2, CatmullRom = 3, Gaussian = 4, Lanczos3 = 5
    #[wasm_bindgen]
    pub fn resize(
        photon_img: &PhotonImage,
        width: u32,
        height: u32,
        sampling_filter: SamplingFilter,
    ) -> PhotonImage {
        let resized_img = resize_internal(photon_img, width, height, sampling_filter);
    
        PhotonImage {
            raw_pixels: resized_img.raw_pixels(),
            width: resized_img.width(),
            height: resized_img.height(),
        }
    }
    
    fn resize_internal(
        photon_img: &PhotonImage,
        width: u32,
        height: u32,
        sampling_filter: SamplingFilter,
    ) -> DynamicImage {
        let sampling_filter = filter_type_from_sampling_filter(sampling_filter);
    
        let dyn_img = helpers::dyn_image_from_raw(&photon_img);
        let resized_img = image::ImageRgba8(image::imageops::resize(
            &dyn_img,
            width,
            height,
            sampling_filter,
        ));
    
        return resized_img;
    }
    I though the main resize logic is called with this line image::imageops::resize(&dyn_img, width, height, sampling_filter), but I must made a mistake as this code does neither resize on nodejs nor natively in rust.
    Coral Lee
    @ScarboroughCoral
    Oh, I love this repo!!! Today I come out that a wasm site for image to html/css, and I seach on Github, found this excellent repo!!
    Coral Lee
    @ScarboroughCoral
    If there are some good first issues or some easy issues please @ me. I am a rust beginner and I have learned about Digital Image Progress in University, there is a (repo)[https://github.com/ScarboroughCoral/DIPModule] for me
    Silvia O'Dwyer
    @silvia-odwyer
    @ScarboroughCoral Glad you're interested in the library, all contributions are welcomed! I just merged your PR which adds a build badge to the README, thanks for your contribution there! If you have any filters you'd like to be implemented, they're always welcome too :D
    Gaurav Patel
    @gp-97
    @silvia-odwyer What are some future plans for "photon"? Any new features, efffects, filters, etc that you would like to have in "photon"?
    Silvia O'Dwyer
    @silvia-odwyer
    @gp-97 I'd love to include color curves also, it would make for very flexible effects! But any new filters and effects are more than welcome! :-)
    Gaurav Patel
    @gp-97
    Oh cool. Noice
    Lakelezz
    @Lakelezz
    hello, i was looking at photon 0.3.1 and saw it mentioning text in docs but it seemingly has been removed, which makes me wonder if this is intentional? as 0.2 still has text support and functions
    Silvia O'Dwyer
    @silvia-odwyer

    @Lakelezz Text support is available in GDL, which is a separate crate that works with Photon. I removed text support in Photon due to the need for extended text functionality, so decided to make a separate crate for it: https://github.com/silvia-odwyer/gdl

    Hope that helps! :-) And do make sure to let me know if you have any other questions, thanks! :D

    Lakelezz
    @Lakelezz
    @silvia-odwyer thank you so much for replying so quickly! photon is using image underneath, is that correct? i'm asking because i found a case where image is unable to load a webp file from memory which is unfortunate as i need to work with them, seems like the alpha channel causes the trouble.
    Silvia O'Dwyer
    @silvia-odwyer
    @Lakelezz Yes, photon is using the image crate underneath. Hmm, that's intriguing, I definitely think you should let the image team know about this by opening an issue, they should be able to help you out! :-)
    arief nur andono
    @goldalworming
    hi, How to blend images with nodejs
    image.png
    I got this error when try to merge
    Silvia O'Dwyer
    @silvia-odwyer
    @goldalworming I'll take a look into this for you! :-)
    MrKomodoDragon
    @MrKomodoDragon
    does photon have any plans for gif support?
    Silvia O'Dwyer
    @silvia-odwyer
    @MrKomodoDragon There are plans for GIF support, however the encoding time for GIFs is quite slow when using the image crate for now. Hopefully this will improve in time; you can track the progress of this feature in this issue here: silvia-odwyer/photon#60
    Thanks again, and let me know if you have any other questions/requests! :-)
    Aaron
    @AJTJ
    How big is the photon binary?
    Silvia O'Dwyer
    @silvia-odwyer
    @AJTJ The wasm file is 957kb at the moment, but the package is optimized for speed instead of size, so further reductions could be applied to the wasm binary size if needed. Hope that helps and let me know if you have other questions! :-)
    g8up
    @g8up
    Silvia O'Dwyer
    @silvia-odwyer
    @g8up Hi there, what kind of sample are you looking for btw, would it be a demo
    Raphael Campardou
    @ralovely
    Hello @silvia-odwyer Photon looks great.
    Do you have any plan to add image distortion (like imagemagick -distort) to it? I'm not sure imageproc supports distortion in the first place, though.
    Thank you.
    Brock Wilcox
    @awwaiid

    Greetings! I'm trying to make a browser-side image filter (vuejs). I have an img element shown on the screen, and the host serving the image is purposely giving Access-Control-Allow-Origin: *. Still, when I try to open_image I am getting SecurityError: The operation is insecure. from photon. Her is a code snippet:

            const img = this.$refs.previewImage;
            const canvas = document.createElement("canvas");
            canvas.width = img.width;
            canvas.height = img.height;
            const ctx = canvas.getContext('2d');
            ctx.drawImage(img, 0, 0);
            const photonImg = photon.open_image(canvas, ctx);
            photon.filter(photonImg, "radio");
            // photon.grayscale(photonImg);
            photon.putImageData(canvas, ctx, img);

    Any tips?

    Brock Wilcox
    @awwaiid
    I added crossorigin="anonymous" directly to the img tag and that fixed it
    Silvia O'Dwyer
    @silvia-odwyer
    @ralovely Hi Raphael! Thanks for taking a look at the library! I'll make sure to add image distortion to the backlog, it's a great feature request and would be an excellent addition to the library also :smile:
    @awwaiid Hi Brock! Glad it's fixed now! :smile: Let me know if you have any other questions and I'll be glad to help! :white_check_mark:
    Osman Turan
    @osman-turan

    Hi everyone. I have just pushed my first PR (see: silvia-odwyer/photon#109) and @silvia-odwyer already merged it (thanks!). I want to contribute a little bit more. I have 2 questions for now:

    1. Gamma correction is listed as a planned feature, but the codebase has already some commented-out code related to it.
    2. There is an issue (see: silvia-odwyer/photon#28) related to panic-free functions. I see it was implemented. Then for some reason, it's reversed for save functions. So the issue still stands.

    What's the plan for these issues?

    Silvia O'Dwyer
    @silvia-odwyer
    Hi Osman! Thanks again for your great contributions, including your work on the panic-free functions and your gamma correction feature also. It's much appreciated! In case anyone was wondering as to the implementation details for the above questions, these were covered in the recent PRs/issues submitted, in case anyone was wondering about this! :white_check_mark:
    Osman Turan
    @osman-turan
    Thanks, Silvia! It was a fun experience for me to contribute to this amazing library :tada:
    Oktavian Yoga
    @oktoala
    Hi everyone, I was wondering how to used Sobel, and edge detection function? I used it and the image just turned into black.
    Silvia O'Dwyer
    @silvia-odwyer
    @oktoala This appears to be a bug, they were working initially, but perhaps updates to the image dependency may have led to this. Thanks for reporting it, I'll take a look!
    A. Bos
    @adhesivee
    Hello I try use image_to_bytesonly it seems to produce a Vec<u8>which is too large.
    save_imageimage works just fine.
    I try to output image_to_byteson a http server, and this is resulting into a broken image.
    The bytesize should be around 3272000 bytes, but I get 1000000 bytes in return.
    Allen Wyma
    @HangingClowns
    Hi. I’m curious about passing bytes from an image back into another language. What’s the best way to do that? Would that be native image_to_bytes? What file format is that?
    I’m reading bytes from one language and passing them into rust, doing some editing and I want to pass the processed bytes back into the original language
    Chris Steffes
    @Pandaphobic
    Hello! Loving Photon in Typescript and wondering - is there is already a type for PhotonImage on the Typescript side?
    Chris Steffes
    @Pandaphobic
    There most certainly is, my imports were wrong. Cheers!
    Silvia O'Dwyer
    @silvia-odwyer
    @Pandaphobic Thanks for trying out Photon! Indeed, the wasm-bindgen CLI tool also outputs types for Typescript, so those types are provided as part of the npm package. If you have any other questions, be sure to let me know :D
    Xander Jake
    @XanderJakeQ_twitter
    hi I'm looking to imitate this photoshop setup.
    is it possible?
    image.png
    the bottom layer is the main image.
    on top of it is a solid color layer on overlay mode
    on top of that is a normal layer with blobs of color used as a clipping mask for the
    the topmost layer, also a solid color but on Color dodge mode
    Silvia O'Dwyer
    @silvia-odwyer
    Hi Xander! Thanks for your question, Photon has a blend function which supports various blending modes, including those you mentioned such as overlay and color dodge. The full documentation is here: https://docs.rs/photon-rs/0.3.1/photon_rs/multiple/fn.blend.html
    You could use this to blend two images with a particular blending mode, so that should be what you're looking for to recreate the setup above.
    Hope that helps, and let me know if you have other questions! :smile:
    Xander Jake
    @XanderJakeQ_twitter
    thanks!!
    how do I set alpha channels? I want to remove black pixels
    Etherll
    @Etherll
    how can i draw text ?
    Silvia O'Dwyer
    @silvia-odwyer
    @Etherll Hi there! It used to be available in version 0.2.0, but it was moved to the gdl library instead: https://github.com/silvia-odwyer/gdl This was done to separate the text drawing functionality and add it to its own library, so that more customization can be supported and so forth. Hope that helps :D
    Freddy Thobhani
    @thobhanifreddy
    Hello, I am having this issue with photon-web as mentioned here. Can anyone help me with this please silvia-odwyer/photon#130
    Joseph
    @JRedOW
    When will the crop patch (silvia-odwyer/photon@35adb2c) be pushed to the create?
    Joseph
    @JRedOW
    @silvia-odwyer
    Greg Barcza
    @gregbarcza
    hey guys, is there a solution for adding borders to images? sg like: https://www.imagemagick.org/Usage/crop/#border