png - Rust 中的图像处理库

标签 png rust libpng

我正在尝试用 Rust 为类(class)项目制作一个基本的图像处理程序,但我不知道如何开始。我研究过使用 rust-png ,但我很难理解如何将它用作外部库,因为我不确定是否正确链接了文件。当我编译 lib.rs 以创建 crate 时,出现此错误。

error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-o' 'main' 'main.o' '-lmorestack' '-nodefaultlibs' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libnative-83574243-0.11-pre.rlib' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-aad93cea-0.11-pre.rlib' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-8f65d5a8-0.10-pre.rlib' '-L/Users/brianuosseph/Desktop/Course_Work/Spring_2014/CS_4414/final_project/.rust' '-L/Users/brianuosseph/Desktop/Course_Work/Spring_2014/CS_4414/final_project' '-lpng' '-lz' '-lshim' '-lSystem' '-lc' '-lm' '-Wl,-rpath,@loader_path/../../../../../../../usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-Wl,-rpath,/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-lcompiler-rt'
note: ld: warning: directory not found for option '-L/Users/brianuosseph/Desktop/Course_Work/Spring_2014/CS_4414/final_project/.rust'
ld: library not found for -lshim
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error

我目前正在运行 Rust 的 0.11-pre-nightly 版本。

对于该项目,我将首先使用 libpng 包装,但将来我更愿意从头开始并为 Rust 创建自己的 PNG 库。然而,我根本不知道从哪里开始,也不知道是否有任何现有的 Rust 图像库,无论是 PNG、GIF 还是 JPEG。有知道的吗?

最佳答案

我为 LodePNG 编写了一个包装器:

https://lib.rs/lodepng

它不需要任何外部库(除了静态链接的 lodepng.c,它包含在内),因此链接它不会有任何问题。


我还为 MozJPEG 编写了绑定(bind)和 makefile,它为您提供了低级 libjpeg API:

https://lib.rs/mozjpeg-sys

关于png - Rust 中的图像处理库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22997888/

相关文章:

Windows 7 上 png_set_read_fn() 崩溃

c++ - 将 PNG 图像作为 vector 或数组嵌入到 C++ 中

javascript - 是否可以进行 HTML5 命中检测?

c++ - 为什么 PNG 图像的标准输出有时会在 printf 中刷新到图像的一半?

javascript - 尝试将 base64 图像加载到 Canvas 中

rust - Rust 编译器在多大程度上自动匹配泛型约束?

rust - 如果不是为了对象安全,Rust 的哪些安全保证会丢失?

php - header ('Content-Type: image/png' );不工作了?

rust - 无法创建目录时出现 panic

android - 更新 opencv 库后仍存在 Libpng 漏洞问题