You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on a project in Rust to extract images from PDF files. I have successfully used the pdf crate to extract JPEG images from PDFs, but I am unsure how to extract PNG images.
Specifically, I am able to extract JPEG images with the following code, but I would like to know how to modify it to extract PNG images instead: https://github.com/abskihDDloh/pdf_to_image_rs
If I add the contents as shown in src/get_image_from_pdf.rs (Near line 253.) , I will get a binary file that is not recognized as an image.
Before:
let ext = match filter {Some(StreamFilter::DCTDecode(_)) => "jpg",Some(StreamFilter::JBIG2Decode(_)) => "jbig2",Some(StreamFilter::JPXDecode) => "jp2k",
After:
let ext = match filter {Some(StreamFilter::DCTDecode(_)) => "jpg",Some(StreamFilter::JBIG2Decode(_)) => "jbig2",Some(StreamFilter::JPXDecode) => "jp2k",Some(StreamFilter::FlateDecode(_)) => "png",
Could someone please advise on how to extract PNG images from a PDF using the pdf crate?
Thank you for your help.
The text was updated successfully, but these errors were encountered:
Hello,
I am currently working on a project in Rust to extract images from PDF files. I have successfully used the pdf crate to extract JPEG images from PDFs, but I am unsure how to extract PNG images.
Specifically, I am able to extract JPEG images with the following code, but I would like to know how to modify it to extract PNG images instead:
https://github.com/abskihDDloh/pdf_to_image_rs
If I add the contents as shown in src/get_image_from_pdf.rs (Near line 253.) , I will get a binary file that is not recognized as an image.
Before:
After:
Could someone please advise on how to extract PNG images from a PDF using the pdf crate?
Thank you for your help.
The text was updated successfully, but these errors were encountered: