如何在在Windows 10上安装OpenJPEG

微软Microsoft Edge插件网 4年前 (2021-01-13) 2127次浏览 已收录 0个评论

Windows 11 Pro ISO文件在哪下载最新版?如何下载原装纯净版Win11 ?点击进入   持续更新!

在Windows 10上安装OpenJPEG

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

为什么要安装GrokImageCompression?

原始JPEG 2000标准仅包含三个颜色编码声明:sGray,sYCC和sRGB。随着色彩管理的普及,图像中嵌入了多种颜色编码显示配置文件,对该标准进行了修订(15444-1annexi.pdf),以适应受限的ICC配置文件的使用。

从openjp2库v2.3.1开始。,OpenJPEG不会继承源图像中嵌入的显示配置文件,而是在输出时将图像颜色空间转换为sRGB。

GrokImageCompression是基于OpenJPEG代码的开源JP2编码器,可成功生成使用与源图像中相同的色彩空间(和ICC显示配置文件)编码的JP2图像。

1.安装Ubuntu 20.04 LTS

从Windows App Store下载 Ubuntu

请遵循Microsoft的安装说明

  • 通过运行以下命令来更新安装: sudo apt-get update ; sudo apt-get upgrade -y
  • 安装一些其他软件模块:sudo 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++

2.通过编译源代码安装OpenJPEG:

  • mkdir ~/install
  • cd ~/install
  • 下载源代码: wget https://github.com/uclouvain/openjpeg/archive/master.zip

按照OpenJPEG安装的安装说明进行操作。

  • unzip master.zip
  • cd openjpeg-master/
  • mkdir build
  • cd build
  • cmake .. -DCMAKE_BUILD_TYPE=Release
  • make
  • sudo make install
  • sudo make clean

3.从源代码安装imagemagick:

请遵循ImageMagick的安装说明

  • cd ~/install
  • rm master.zip
  • wget https://github.com/ImageMagick/ImageMagick/archive/master.zip
  • unzip master.zip
  • cd 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-shared
  • sudo make
  • sudo make install
  • sudo make clean

4.安装GrokImageCompression

遵循GrokImageCompression安装说明

  • cd ~/install
  • rm master.zip
  • wget https://github.com/GrokImageCompression/grok/archive/master.zip
  • unzip master.zip
  • cd grok-master
  • mkdir build
  • cd build
  • cmake -DCMAKE_BUILD_TYPE=Release ..
  • make
  • sudo make install
  • sudo make clean

5.测试您的安装

  • mkdir ~/images
  • cd ~/images
  • wget 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 '<isValid format="jp2">True</isValid>'

编码JP2文件

  • 命令:opj_compressgrk_compress
  • 开关:
    • -i <inputFile.ext>
    • -p RLCP (进度顺序)
    • -t 1024,1024 (大小)
    • -EPH (数据包标题标记的结尾)
    • -SOP (数据包开始)
    • -ImgDir <image dir>(不能与-i开关一起使用)
    • -OutFor <ext> (输出文件的扩展名)
    • -o <outputFile.ext>
    • -I (指定有损编码)
    • -q <quality in dB>,<quality in dB>,...
    • -r <compression ratio>,<compression ratio>,...

无损示例

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 42
  • opj_compress -i in.tif -o out_lossy_r10.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -r 10

  • grk_compress -i in.tif -o grk_out_lossy_42db.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -I -q 42
  • grk_compress -i in.tif -o grk_out_lossy_r10.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -r 10

解压缩:将JP2文件转换为其他格式

  • opj_decompress -i infile.j2k -o outfile.png
  • opj_decompress -ImgDir images/ -OutFor tif

  • grk_decompress -i infile.j2k -o outfile.png
  • grk_decompress -ImgDir images/ -OutFor tif

结束


Installing OpenJPEG on Windows 10

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 OpenJPEGImageMagick, 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

Why install GrokImageCompression?

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.

1. Install Ubuntu 20.04 LTS

From the Windows App Store, download Ubuntu.

Follow Microsoft’s installation instructions.

  • Update the installation by running the following command: sudo apt-get update ; sudo apt-get upgrade -y
  • Install some additional software modules: sudo 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++.

2. Install OpenJPEG by compiling the source code:

  • mkdir ~/install
  • cd ~/install
  • Download the source code: wget https://github.com/uclouvain/openjpeg/archive/master.zip

Follow the installation instructions, per OpenJPEG installation.

  • unzip master.zip
  • cd openjpeg-master/
  • mkdir build
  • cd build
  • cmake .. -DCMAKE_BUILD_TYPE=Release
  • make
  • sudo make install
  • sudo make clean

3. Install imagemagick from source code:

Follow the ImageMagick installation instructions

  • cd ~/install
  • rm master.zip
  • wget https://github.com/ImageMagick/ImageMagick/archive/master.zip
  • unzip master.zip
  • cd ImageMagick-master

Make 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-shared
  • sudo make
  • sudo make install
  • sudo make clean

4. Install GrokImageCompression

Follow the GrokImageCompression installation instructions

  • cd ~/install
  • rm master.zip
  • wget https://github.com/GrokImageCompression/grok/archive/master.zip
  • unzip master.zip
  • cd grok-master
  • mkdir build
  • cd build
  • cmake -DCMAKE_BUILD_TYPE=Release ..
  • make
  • sudo make install
  • sudo make clean

5. Test your installation

  • mkdir ~/images
  • cd ~/images
  • wget https://github.com/harvard-library-imaging-services/images/raw/master/in.tif

Run the following commands:

Testing ImageMagick installation

  • convert in.tif out_via_imagemagick.jp2 | exiftool out_via_imagemagick.jp2 | less

Testing 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 42

Testing 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 42

Are the JP2 files you created standard-compliant?

  • jpylyzer *.jp2 | grep '<isValid format="jp2">True</isValid>'

Encoding JP2 files

  • Command: opj_compress and grk_compress
  • Switches:
    • -i <inputFile.ext>
    • -p RLCP (progression order)
    • -t 1024,1024 (tile size)
    • -EPH (End of Packet Header marker)
    • -SOP (Start of Packet)
    • -ImgDir <image dir> (cannot be used with -i switch)
    • -OutFor <ext> (extension for output files)
    • -o <outputFile.ext>
    • -I (specifies lossy encoding)
    • -q <quality in dB>,<quality in dB>,...
    • -r <compression ratio>,<compression ratio>,...

Lossless example

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

Lossy example

  • opj_compress -i in.tif -o out_lossy_42db.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -I -q 42
  • opj_compress -i in.tif -o out_lossy_r10.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -r 10

  • grk_compress -i in.tif -o grk_out_lossy_42db.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -I -q 42
  • grk_compress -i in.tif -o grk_out_lossy_r10.jp2 -p RLCP -t 1024,1024 -EPH -SOP -OutFor jp2 -r 10

Decompress: converting JP2 files to other formats

  • opj_decompress -i infile.j2k -o outfile.png
  • opj_decompress -ImgDir images/ -OutFor tif

  • grk_decompress -i infile.j2k -o outfile.png
  • grk_decompress -ImgDir images/ -OutFor tif

end

下载最新版Windows 11 Pro ISO文件:点击进入   持续更新原装纯净版Win11 

Edge插件网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在在Windows 10上安装OpenJPEG
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址