Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
import java.io.*;
import java.awt.image.*;
import javax.imageio.*;
import java.awt.*;
public class BildSkalierer implements ImageObserver {
//Bild skalieren
BufferedImage bild = null;
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
return false;
}
public void bildSkalieren(File image, int breite, int höhe) {
//Bilddatei öffnen
try {
bild = ImageIO.read(image);
} catch(Exception e) {
e.printStackTrace();
return;
}
if(bild == null)
return;
BufferedImage neuesBild = new BufferedImage(breite, höhe, BufferedImage.TYPE_INT_RGB);
Graphics2D g = neuesBild.createGraphics();
//Bild skalieren
g.drawImage(bild.getScaledInstance(breite, höhe, Image.SCALE_SMOOTH), 0, 0, breite, höhe, this);
if(neuesBild == null)
return;
//Bild speichern
try {
ImageIO.write(neuesBild, image.getName().substring(image.getName().lastIndexOf(".") + 1, image.getName().length()), image);
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
if(args[0] == null)
return;
BildSkalierer scale = new BildSkalierer();
scale.bildSkalieren(new File(args[0]), 600, 400);
}
}