[] Images transcoding ?

General discussion about Universal Media Server (no support or requests)
Post Reply
User avatar
Sami32
Posts: 822
Joined: Mon Apr 11, 2016 5:09 am

[] Images transcoding ?

Post by Sami32 » Mon Jun 06, 2016 1:49 pm

Hello,

Sanselan, TwelveMonkeys, Metadata-extractor or FFMpeg can do the job, but i'm not skilled to know which one will use less CPU and less memory for that purpose.

Code: Select all

ffmpeg -i input.png -pix_fmt yuvj420p output.jpg
will do the job.

Or this sample of code taken on the Web :

Code: Select all

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

public class Tiff2JpgTest {

public static void main(String args[])
{
    try
    {
        BufferedImage image = ImageIO.read(new File("test.tiff"));
        image = convert(image, BufferedImage.TYPE_INT_RGB);
        ImageIO.write(image, "jpg", new File("test.jpg"));
        System.out.println("done.");
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
}

public static BufferedImage convert(BufferedImage src, int bufImgType) {
    BufferedImage img= new BufferedImage(src.getWidth(), src.getHeight(), bufImgType);
    Graphics2D g2d= img.createGraphics();
    g2d.drawImage(src, 0, 0, null);
    g2d.dispose();
    return img;
}
}
But, if anyone was interested, some more metadatas will need to be extracted to get a more precise, correct renderer's configuration ( CMYK and Progressive attribute write in the supported formats ).
DLNAMediaInfo.java could need some getImageInfo adds like :

Code: Select all

isProgressive()
and

Code: Select all

getColorType()
?

Just some ideas that i got when i was reading some posts on this forum :roll:

EDIT : On his way..., thank very much to @Valib :D
https://github.com/UniversalMediaServer ... r/pull/911
https://github.com/UniversalMediaServer ... issues/886

Post Reply