OpenJPEG是用C编写的开源JPEG 2000编解码器。没有GUI。使用命令行友好的操作系统(如Linux)可以轻松运行和维护此命令行工具,因此,我建议利用W10的Windows Subsystem for Linux功能在Windows 10计算机上安装Linux 。
以下是从源代码编译OpenJPEG,ImageMagic k和GrokImageCompression的说明。
尽管使用apt通过预编译的版本安装OpenJPEG和ImageMagick更加容易,但是我在编译源代码时可以解决以前的安装问题,所以建议这样做。请注意,您根本不需要安装ImageMagick,但这是一个非常有用的实用程序。
如果您想先尝试通过预编译版本安装OpenJPEG,则可以使用以下命令解决问题:
sudo apt install libopenjp2-7 libopenjp2-tools
原始JPEG 2000标准仅包含三个颜色编码声明:sGray,sYCC和sRGB。随着色彩管理的普及,图像中嵌入了多种颜色编码显示配置文件,对该标准进行了修订(15444-1annexi.pdf),以适应受限的ICC配置文件的使用。
从openjp2库v2.3.1开始。,OpenJPEG不会继承源图像中嵌入的显示配置文件,而是在输出时将图像颜色空间转换为sRGB。
GrokImageCompression是基于OpenJPEG代码的开源JP2编码器,可成功生成使用与源图像中相同的色彩空间(和ICC显示配置文件)编码的JP2图像。
从Windows App Store下载 Ubuntu。
请遵循Microsoft的安装说明。
sudo apt-get update ; sudo apt-get upgrade -ysudo apt-get install pkg-config emacs-nox python3-jpylyzer libltdl-dev libopenjp2-7-dev libtiff-tools exiftool git git-lfs cmake liblcms2-dev libtiff-dev libpng-dev libz-dev unzip libzstd-dev libwebp-dev build-essential g++。mkdir ~/installcd ~/installwget https://github.com/uclouvain/openjpeg/archive/master.zip按照OpenJPEG安装的安装说明进行操作。
unzip master.zipcd openjpeg-master/mkdir buildcd buildcmake .. -DCMAKE_BUILD_TYPE=Releasemakesudo make installsudo make clean请遵循ImageMagick的安装说明
cd ~/installrm master.zipwget https://github.com/ImageMagick/ImageMagick/archive/master.zipunzip master.zipcd ImageMagick-master确保系统看到由刚创建的libopenjp2.pc文件
config。要查找libopenjp2.pc文件:find ~ -type f | grep libopenjp2.pc
sudo pkg-config PKG_CONFIG_PATH=~/install/openjpeg-master/build./configure --enable-sharedsudo makesudo make installsudo make clean遵循GrokImageCompression安装说明
cd ~/installrm master.zipwget https://github.com/GrokImageCompression/grok/archive/master.zipunzip master.zipcd grok-mastermkdir buildcd buildcmake -DCMAKE_BUILD_TYPE=Release ..makesudo make installsudo make cleanmkdir ~/imagescd ~/imageswget https://github.com/harvard-library-imaging-services/images/raw/master/in.tif测试ImageMagick安装
convert in.tif out_via_imagemagick.jp2 | exiftool out_via_imagemagick.jp2 | less测试OpenJPEG安装(有损压缩示例)
opj_compress -i in.tif -o out_lossy_42db.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -I -q 42测试GrokImageCompression安装(有损压缩示例)
grk_compress -i in.tif -o grk_out_lossy_42db.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -I -q 42您创建的JP2文件是否符合标准?
jpylyzer *.jp2 | grep \'True \'opj_compress和grk_compress-i -p RLCP (进度顺序)-t 1024,1024 (大小)-EPH (数据包标题标记的结尾)-SOP (数据包开始)-ImgDir (不能与-i开关一起使用)-OutFor (输出文件的扩展名)-o -I (指定有损编码)-q ,,... -r ,,... opj_compress -i in.tif -o out_lossless.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2
grk_compress -i in.tif -o grk_out_lossless.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2
opj_compress -i in.tif -o out_lossy_42db.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -I -q 42opj_compress -i in.tif -o out_lossy_r10.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -r 10grk_compress -i in.tif -o grk_out_lossy_42db.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -I -q 42grk_compress -i in.tif -o grk_out_lossy_r10.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -r 10opj_decompress -i infile.j2k -o outfile.pngopj_decompress -ImgDir images/ -OutFor tifgrk_decompress -i infile.j2k -o outfile.pnggrk_decompress -ImgDir images/ -OutFor tif结束
OpenJPEG is an open-source JPEG 2000 codec written in C. There is no GUI. This command-line tool is easy to run and maintain using a command-line friendly OS like Linux, so I recommend installing Linux on your Windows 10 machine, taking advantage of W10\’s Windows Subsystem for Linux feature.
Below are instructions for compiling OpenJPEG, ImageMagick, and GrokImageCompression from source code.
While it is easier to install OpenJPEG and ImageMagick via pre-compiled versions using apt, I\’ve had issues with prior installations that I resolved by compiling the source code, so that is what I recommend. Note that you do not need to install ImageMagick at all, but it is a very useful utility.
If you\’d like to try installing OpenJPEG via the precompiled version first, the following command should do the trick:
sudo apt install libopenjp2-7 libopenjp2-tools
The original JPEG 2000 standard only accommodated three color encoding declarations: sGray, sYCC, and sRGB. As color management gained popularity, and a wider variety of color encoding display profiles were being embedded in images, the standard was amended (15444-1annexi.pdf) so accommodate the use of restricted ICC profiles .
As of the openjp2 library v2.3.1., OpenJPEG does not carry over the display profiles embedded within the source image, but instead converts the image colorspace to sRGB on output.
GrokImageCompression is an open-source JP2 encoder based on the OpenJPEG code that successfully generates JP2 images encoded with the same colorspace (and ICC display profile) found in the source image.
From the Windows App Store, download Ubuntu.
Follow Microsoft\’s installation instructions.
sudo apt-get update ; sudo apt-get upgrade -ysudo apt-get install pkg-config emacs-nox python3-jpylyzer libltdl-dev libopenjp2-7-dev libtiff-tools exiftool git git-lfs cmake liblcms2-dev libtiff-dev libpng-dev libz-dev unzip libzstd-dev libwebp-dev build-essential g++.mkdir ~/installcd ~/installwget https://github.com/uclouvain/openjpeg/archive/master.zipFollow the installation instructions, per OpenJPEG installation.
unzip master.zipcd openjpeg-master/mkdir buildcd buildcmake .. -DCMAKE_BUILD_TYPE=Releasemakesudo make installsudo make cleanFollow the ImageMagick installation instructions
cd ~/installrm master.zipwget https://github.com/ImageMagick/ImageMagick/archive/master.zipunzip master.zipcd ImageMagick-masterMake sure system sees the libopenjp2.pc file just created by
config. To look for the libopenjp2.pc files:find ~ -type f | grep libopenjp2.pc
sudo pkg-config PKG_CONFIG_PATH=~/install/openjpeg-master/build./configure --enable-sharedsudo makesudo make installsudo make cleanFollow the GrokImageCompression installation instructions
cd ~/installrm master.zipwget https://github.com/GrokImageCompression/grok/archive/master.zipunzip master.zipcd grok-mastermkdir buildcd buildcmake -DCMAKE_BUILD_TYPE=Release ..makesudo make installsudo make cleanmkdir ~/imagescd ~/imageswget https://github.com/harvard-library-imaging-services/images/raw/master/in.tifTesting ImageMagick installation
convert in.tif out_via_imagemagick.jp2 | exiftool out_via_imagemagick.jp2 | lessTesting OpenJPEG installation (lossy compression example)
opj_compress -i in.tif -o out_lossy_42db.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -I -q 42Testing GrokImageCompression installation (lossy compression example)
grk_compress -i in.tif -o grk_out_lossy_42db.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -I -q 42Are the JP2 files you created standard-compliant?
jpylyzer *.jp2 | grep \'True \'opj_compress and grk_compress-i -p RLCP (progression order)-t 1024,1024 (tile size)-EPH (End of Packet Header marker)-SOP (Start of Packet)-ImgDir (cannot be used with -i switch)-OutFor (extension for output files)-o -I (specifies lossy encoding)-q ,,... -r ,,... opj_compress -i in.tif -o out_lossless.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2
grk_compress -i in.tif -o grk_out_lossless.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2
opj_compress -i in.tif -o out_lossy_42db.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -I -q 42opj_compress -i in.tif -o out_lossy_r10.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -r 10grk_compress -i in.tif -o grk_out_lossy_42db.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -I -q 42grk_compress -i in.tif -o grk_out_lossy_r10.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -r 10opj_decompress -i infile.j2k -o outfile.pngopj_decompress -ImgDir images/ -OutFor tifgrk_decompress -i infile.j2k -o outfile.pnggrk_decompress -ImgDir images/ -OutFor tifend
下载最新版Windows 11 Pro ISO文件:点击进入 持续更新原装纯净版Win11