简体   繁体   中英

ImageIO.write doesn't work with jpg

I'm using this to write an image:

String fileURL = Context.getContext().gets("appPath") + "upload/tmp/" + i + ".jpg";
ImageIO.write((RenderedImage) img, "jpg", new File(fileURL));

It works on my computer, but not on the server. On the server, ImageIO.write returns false .

Also, if I run ImageIO.getImageWritersByFormatName() , the returned list doesn't contain jpg in it.

I can write the image with png format, but I need it in jpg .

Most likely your server does not have X11 running. This is a Java (AWT/Java2D) issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM