opj_compress(1)
π opj_compress β the manual page, but make it make sense π
okay bestie, sit down, hydrate, because this is the tool that turns your regular little images into β¨jpeg2000β¨ files. it's part of the OpenJPEG library, and the manual page for it lives in section 1 (opj_compress(1)) β the "converts to jpeg2000 files" corner of the man universe. π¦
πΈ NAME πΈ
opj_compress β this program reads in an image of a certain type and converts it to a jpeg2000 file. it's part of the OpenJPEG library. no cap.
Valid input image extensions are .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif. For PNG resp. TIF it needs libpng resp. libtiff. (so like, if you're trying to feed it a PNG and it's acting brand new, that's why β go get the library. π)
Valid output image extensions are .j2k, .jp2. that's it, that's the whole vibe. π
β¨ SYNOPSIS β¨
opj_compress -i infile.bmp -o outfile.j2k
opj_compress -ImgDir directory_name -OutFor jp2
opj_compress -h Print a help message and exit.
See JPWL OPTIONS for special options (yes, they get their own whole section, main character energy fr fr π ).
π OPTIONS π
-bn,n β size of code block (e.g.-b 32,32). Default:64 x 64.-cn β size of precinct (e.g.-c 128,128). Default:2^15 x 2^15.-cinema2Kfps β Digital Cinema 2K profile compliant codestream. Valid fps values are24or48. those are the only two, don't try to be creative. π-cinema4Kβ Digital Cinema 4K profile compliant codestream. does not need an fps: default is24fps. she's self-sufficient. π-dX,Y β offset of image origin (e.g.-d 150,300).-hβ print a help message and exit. the classic "what do I do" button. π«Ά-iname β input file name.-nn β number of resolutions. Default:6.-oname β output file name.-pname β progression order. name can be one out of:LRCP,RLCP,RPCL,PCRL,CPRL. Default:LRCP.-qn β different psnr for successive layers.
Note: options-rand-qcannot be used together. pick a lane, bestie. π
-rn β different compression ratio(s) for successive layers. the rate specified for each quality level is the desired compression factor.
Note: options-rand-qcannot be used together.
-sX,Y β sub-sampling factor (e.g.-s 2,2). Default: no sub-sampling in x or y direction.
Remark: sub-sampling bigger than2can produce errors. so like, stay in your lane at2and below, okay? β οΈ
-tW,H β size of tile (e.g.-t 512,512).-xname β create index file and fill it. Default: no index file.-EPHβ write EPH marker after each header packet. Default: no EPH.-FrawWidth,rawHeight,rawComp,rawBitDepth,s_or_u β characteristics of the raw input image.-Iβ use the irreversible DWT 9-7. Default: reversible DWT 5-3. (irreversible?? she's chaotic but she serves π)-ImgDirdirectory_name β directory containing input files.-Mn β mode switch with values:1,2,4,8,16,32. Default: no mode switch activated.
Meaning:
BYPASS(1)
RESET(2)
RESTART(4)
VSC(8)
ERTERM(16)
SEGMARK(32)
Values can be added: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38 β yes bestie, it's math. you can stack them. π₯
-OutForext β extension for output files.-POCTtileNr=resolutionStart, componentStart, layerEnd, resolutionEnd, componentEnd, progressionOrder β see Examples. π-ROIc=n,U=n β quantization indices upshifted for component c (0or1or2) with a value of U (>= 0and<= 37). e.g.-ROI c=0,U=25.-SOPβ write SOP marker before each packet. Default: no SOP marker in the codestream.-TX,Y β offset of the origin of the tiles (e.g.-T 100,75).-Wβ see JPWL OPTIONS. (she's a gateway option, iykyk π)
π JPWL OPTIONS π
Options usable only if the library has been compiled with -DUSE_JPWL. (so if these do nothing for you... that's why, and no, it's not your fault. π)
-Wh<tilepart><=type>,s<tilepart><=method>,a=<addr>,z=<size>,g=<range>,p<tilepart:pack><=type>hselects the header error protection (EPB): type can be[0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
if tilepart is absent, it is for main and tile headers
if tilepart is present, it applies from that tile onwards, up to the next h<> spec, or to the last tilepart in the codestream (max. 16 specs)
pselects the packet error protection (EEP/UEP with EPBs) to be applied to raw data: type can be[0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
if tilepart:pack is absent, it is from tile 0, packet 0
if tilepart:pack is present, it applies from that tile and that packet onwards, up to the next packet spec or to the last packet in the last tilepart in the stream (max. 16 specs)
senables sensitivity data insertion (ESD): method can be[-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR 4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]
if tilepart is absent, it is for main header only
if tilepart is present, it applies from that tile onwards, up to the next s<> spec, or to the last tilepart in the codestream (max. 16 specs)
gdetermines the addressing mode: range can be[0=PACKET 1=BYTE RANGE 2=PACKET RANGE]adetermines the size of data addressing: addr can be2/4bytes (small/large codestreams). if not set, auto-mode.zdetermines the size of sensitivity values: size can be1/2bytes, for the transformed pseudo-floating point value.
π EXAMPLES π
opj_compress -i file.bmp -o file.j2k -r 20,10,1 (compress 20x, then 10x, then lossless).
opj_compress -i file.ppm -o file.j2k -q 30,40,50
opj_compress -i file.pgx -o file.j2k -POC T1=0,0,1,5,3,CPRL
opj_compress -i lena.raw -o lena.j2k -F 512,512,3,8,u
π AUTHORS π
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium Copyright (c) 2002-2014, Professor Benoit Macq Copyright (c) 2001-2003, David Janssens Copyright (c) 2002-2003, Yannick Verschueren Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe Copyright (c) 2005, Herve Drolon, FreeImage Team Copyright (c) 2006-2007, Parvatha Elangovan
(genuinely iconic lineup, they built the whole thing, show some respect π«Ά)
π¦ SEE ALSO π¦
okay that's the whole page, bestie!! this came to you from opj_compress, Version 2.1.1 β go forth and compress, you absolute legend. β¨ππ πΈπ«Ά
π¦ where this page comes from
- arch rolling: openjpeg2 2.5.4-1 Β· BSD-2-Clause AND MIT
- debian bookworm: libopenjp2-tools 2.5.0-2+deb12u3 Β· BSD-2
- debian trixie: libopenjp2-tools 2.5.3-2.1~deb13u2 Β· BSD-2
- fedora 43: openjpeg-tools 2.5.4-1.fc43 Β· BSD-2-Clause AND MIT
- fedora 43: openjpeg-tools 2.5.4-1.fc43 Β· BSD-2-Clause AND MIT
- fedora 44: openjpeg-tools 2.5.4-3.fc44 Β· BSD-2-Clause AND MIT
- fedora 44: openjpeg-tools 2.5.4-3.fc44 Β· BSD-2-Clause AND MIT
- fedora 44: openjpeg-tools 2.5.4-5.fc44 Β· BSD-2-Clause AND MIT
- fedora 44: openjpeg-tools 2.5.4-5.fc44 Β· BSD-2-Clause AND MIT
- opensuse-leap 16.0: openjpeg2 2.5.3-160000.4.1 Β· BSD-2-Clause
- opensuse-leap 16.0: openjpeg2 2.5.3-160000.4.1 Β· BSD-2-Clause
- opensuse-leap 16.0: openjpeg2 2.5.3-160000.4.1 Β· BSD-2-Clause
- opensuse-leap 16.0: openjpeg2 2.5.3-160000.4.1 Β· BSD-2-Clause
- ubuntu jammy: libopenjp2-tools 2.4.0-6 Β· BSD-2
- ubuntu jammy: libopenjp2-tools 2.4.0-6ubuntu0.5 Β· BSD-2
- ubuntu noble: libopenjp2-tools 2.5.0-2build3 Β· BSD-2
- ubuntu noble: libopenjp2-tools 2.5.0-2ubuntu0.5 Β· BSD-2
- ubuntu questing: libopenjp2-tools 2.5.3-2.1
- ubuntu questing: libopenjp2-tools 2.5.3-2.1ubuntu0.1
- ubuntu resolute: libopenjp2-tools 2.5.4-1 Β· BSD-2
- ubuntu resolute: libopenjp2-tools 2.5.4-1ubuntu0.1 Β· BSD-2
- ubuntu stonking: libopenjp2-tools 2.5.4-1.1 Β· BSD-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms