问题描述
所以我编写了一个C ++程序,可以生成非常高分辨率的图片(分形)。
我使用fstream将所有数据保存在.ppm文件中。
So I wrote a C++ program that produces very high resolution pictures (fractals). I use fstream to save all the data in a .ppm file.
一切正常,但当我进入真正的高分辨率(38400x21600)ppm时文件有~8千兆字节。
然而,凭借我的16 GB Ram,我仍然无法转换那张照片。我下载了几个转换器,但他们无法处理它。当我试图导出为......时,甚至Gimp也崩溃了。
Everything works fine, but when I go into really high resolution (38400x21600) the ppm file has ~8 Gigabytes. With my 16 Gigabytes of Ram, however, I am still not able to convert that picture. I downloaded couple of converters, but they couldn't handle it. Even Gimp crashed when I try to "export as...".
那么,有没有人知道一个可以处理真正大ppm文件的好转换器?事实上,我甚至想要超过100千兆字节。我不在乎它是否很慢,它应该工作。
So, does anyone know a good converter that can handle really large ppm files? In fact, I even want to go above 100 Gigabytes. I don't care if it's slow, it should just work.
如果没有这样的转换器:有没有办法以更好的方式使用std :: ofstream?也许,是否有自动生成PNG文件的库?
If there is no such converter: Is there a way to std::ofstream in a better way? Like maybe, is there a library that automaticly produces a PNG file?
感谢您的帮助!
编辑:我也问自己,保存这些大图像的最佳格式是什么。我研究过,JPEG看起来很漂亮(体积小,质量还不错)。但是可能有更好的格式吗?让我知道。谢谢
also I asked myself what might be the best format for saving these large images. I researched and JPEG looks quite pretty (small size, still good quality). But may be there a better format? Let me know. Thanks
推荐答案
一些想法...
8- 38400x21600的位PPM文件应占用2.3GB。相同尺寸的16位PPM文件需要两倍,即4.6GB,所以我不确定你从哪里获得8GB。
An 8-bit PPM file of 38400x21600 should take 2.3GB. A 16-bit PPM file of the same dimensions requires twice as much, i.e. 4.6GB so I am not sure where you got 8GB from.
非常适合处理大型图像,如果我采用38400x21600 PPM文件,在终端中使用以下命令(即命令行),我可以看到它在58MB的RAM处达到峰值,从PPM转换为JPEG ...
VIPS is excellent for processing large images, and if I take a 38400x21600 PPM file, and use the following command in Terminal (i.e. at the command-line), I can see it peaks at 58MB of RAM to do the conversion from PPM to JPEG...
vips jpegsave fractal.ppm fractal.jpg --vips-leak
memory: high-water mark 58.13 MB
在一个合理的规格iMac上需要31秒,并从我的(随机)数据产生一个480MB的文件,所以你会期望你的结果要小得多,因为我很漂亮不可压缩。
That takes 31 seconds on a reasonable spec iMac and produces a 480MB file from my (random) data, so you would expect your result to be much smaller, since mine is pretty incompressible.
另一方面,ImageMagick需要1.1GB峰值工作内存并在74秒内完成相同的转换:
ImageMagick, on the other hand, takes 1.1GB peak working set of memory and does the same conversion in 74 seconds:
/usr/bin/time -l convert fractal.ppm fractal.jpg
73.81 real 69.46 user 4.16 sys
11616595968 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
4051124 page reclaims
4 page faults
0 swaps
0 block input operations
106 block output operations
0 messages sent
0 messages received
0 signals received
9 voluntary context switches
11791 involuntary context switches
这篇关于将非常大的ppm文件转换为JPEG / JPG / PNG?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!