Why is the jpg file that I converted from a gif file not clear and understandable?

I use the following code to convert a gif file to a jpg file, it works, but the result of the jpg file does not match the quality of the original gif file, why? Any way to improve quality?

try
{
  ImageIO.write(ImageIO.read(new File("C:/abc.gif")),"jpg",new File("C:/abc.jpg"));
}
catch (Exception e) { e.printStackTrace(); }

So, to ask this question from a different angle, using the above approach, how to increase output quality?

+3
source share
4 answers

JPEG - , . , , , - .

, ImageIO.write JPEG , , .

, ImageWriteParam, , ImageWriter JPEG.

:

// Get a writer for JPEG.
ImageWriter iw = ImageIO.getImageWritersByFormatName("jpeg").next();
iw.setOutput(new FileImageOutputStream(outputFile));

// Set the compression quality to 0.9f.
ImageWriteParam iwParam = iw.getDefaultWriteParam();
iwParam.setCompressionQuality(0.9f);

// Write image
iw.write(null, new IIOImage(imageToWrite, null, null), iwParam);

:

, , JPEG . , , JPEG, PNG , - . PNG , JPEG. ( .)

, , JPEG, , , PNG, , .

+20

JPEG . .PNG.

+11

JPEG ; . , , .

GIF , JPEG - ; abc.jpg abc.gif.

+5

, JPEG , . , , , JPEG .

If the image is drawn or contains large windings of the same color and is not photographic, then the image will be better compressed using PNG. This is a lossless format that can perform 32-bit color.

Nowadays, you should hardly use GIF images - the format only supports 8-bit color and provides relatively low compression.

+2
source

Source: https://habr.com/ru/post/1710038/


All Articles