C、C++或用于将 JPEG 图像转换为 TIFF 格式的 Objective-C 代码

发布于 2024-11-29 14:14:51 字数 102 浏览 10 评论 0原文

我正在寻找一种方法将 JPEG 图像转换为 TIFF 格式,然后将此 TIFF 图像保留为 base64 格式。解决方案可以是 C、C++ 或 Objective C...请告知 提前致谢

I am looking for a method to convert JPEG images to TIFF format then keep this TIFF image in base64 format. The solution can be in C, C++ or objective C ... Please advise
Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青丝拂面 2024-12-06 14:14:51

我以前用过 ImageMagick,效果很好。我使用了 RMagick,Ruby 的绑定,但它们也有 C++ 绑定 。至于将 tiff 图像保持为 base64 格式,您需要另一个库,例如 libb64。 ImageMagick 片段应该像这样简单

#include <Magick++.h> 
#include <iostream> 
using namespace std; 
using namespace Magick;

int main(int argc,char **argv) 
{ 
  Image image;
  try { 
    image.read( "girl.jpg" );

    // convert to tiff
    image.write( "girl.tiff" ); 
  } 
  catch( Exception &error_ ) 
    { 
      cout << "Caught exception: " << error_.what() << endl; 
      return 1; 
    } 
  return 0; 
}

(示例修改自 http://www.imagemagick.org/Magick++ /Image.html

要满足内存要求,很容易。

Image jpg = Image("/path/to/jpg");
jpg.magick("tiff");
Blob blob;
jpg.write(&blob);

我将让您完成了解如何从 blob 获取字节的工作。

I've used ImageMagick before and it works well. I used RMagick, the bindings for Ruby, but they have C++ bindings too. As far as keeping the tiff image in base64 format, you'll want another library like libb64. The ImageMagick piece should be as simple as

#include <Magick++.h> 
#include <iostream> 
using namespace std; 
using namespace Magick;

int main(int argc,char **argv) 
{ 
  Image image;
  try { 
    image.read( "girl.jpg" );

    // convert to tiff
    image.write( "girl.tiff" ); 
  } 
  catch( Exception &error_ ) 
    { 
      cout << "Caught exception: " << error_.what() << endl; 
      return 1; 
    } 
  return 0; 
}

(Example modified from http://www.imagemagick.org/Magick++/Image.html)

To accomodate the in memory requirement, easy enough.

Image jpg = Image("/path/to/jpg");
jpg.magick("tiff");
Blob blob;
jpg.write(&blob);

I'll let you do the work of seeing how you'll get the bytes from the blob.

月野兔 2024-12-06 14:14:51

libgd 或 ImageMagick 应该可以解决问题。

libgd or ImageMagick should do the trick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文