Как использовать libjpeg в JavaJAVA

Программисты JAVA общаются здесь
Anonymous
Как использовать libjpeg в Java

Сообщение Anonymous »

Я хочу использовать Libjpeg в Spring Boot, но я не могу найти доступный пакет зависимости, так что не могли бы вы мне помочь? Ошибка не согласна на Br/P>
Мое устройство-Apple Mac M2, и мне также необходимо использовать Libjpeg на linux.
jar path: /susers/lush/code/image-kit/image-kit-component/src/main/resourcess/turbojpeg-trishpeg-himage-kit-component/src/main/resourcess/turbojpeg-frypeg-jarbejpeg-jarbejpeg-component/src/main/resourcess/turbojpeg-himage-kit-component/src/main/resourcess/turbojpeg-compontome. /> POM PATH: /USERS/LUSH/CODE/IMAGE-KIT/IMAGE-KIT-Component/pom.xml

pom:

Код: Выделить всё

ome
turbojpeg
8.1.1
system
${project.basedir}/src/main/resources/turbojpeg-8.1.1.jar

< /code>
my code: < /p>
public static byte[] convertPngToJpeg(@NotNull BufferedImage bufferedImage, int quality) throws Exception {
BufferedImage rgbImage = new BufferedImage(
bufferedImage.getWidth(),
bufferedImage.getHeight(),
BufferedImage.TYPE_3BYTE_BGR
);
Graphics2D g = rgbImage.createGraphics();

g.setColor(Color.WHITE);
g.fillRect(0, 0, rgbImage.getWidth(), rgbImage.getHeight());
g.drawImage(bufferedImage, 0, 0, null);
g.dispose();
byte[] bgrData = ((DataBufferByte) rgbImage.getRaster().getDataBuffer()).getData();
int width = rgbImage.getWidth();
int height = rgbImage.getHeight();
int pitch = width * 3;

TJCompressor compressor = null;
try {
compressor = new TJCompressor();
compressor.setSubsamp(TJ.SAMP_420);
compressor.setJPEGQuality(quality);
compressor.setSourceImage(bgrData, 0, pitch, height, TJ.PF_BGR);
byte[] fullBuf = compressor.compress(TJ.FLAG_BOTTOMUP);
int actualSize = compressor.getCompressedSize();
return Arrays.copyOf(fullBuf, actualSize);
} finally {
if (compressor != null) {
compressor.close();
}
}
}
Я хочу преобразовать PNG в JPEG, и мне нужно использовать TJ.SAMP_420.


Подробнее здесь: https://stackoverflow.com/questions/796 ... eg-in-java

Вернуться в «JAVA»