K
koxkor
Hello.
Using the bello code i am trying to resize one image (jpg).
this class is using into one web apllication for resizing jpg images.
in windows it runs well but into my linux i doesn't work.
In linux the program is executed to the:
System.out.println("3.-,,,");
try
{
g = output.createGraphics();
it doesn't continuous where it mades g = output.createGraphics();
if i try to execute into linux from the main, its main method appears
this error:
1.-
2.-
3.-,,,
Exception in thread "main" java.lang.InternalError: Can't connect to
X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:134)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1041)
at RedimensionamientoDeImagenesJPG.redimensionaJPG(RedimensionamientoDeImagenesJPG.java:36)
at RedimensionamientoDeImagenesJPG.main(RedimensionamientoDeImagenesJPG.java:58)
Can you help me to resizing one JSP image?
thanks
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.PrintStream;
import javax.imageio.ImageIO;
public class RedimensionamientoDeImagenesJPG
{
public RedimensionamientoDeImagenesJPG()
{
}
public void redimensionaJPG(int ancho, String ficheroEntrada,
String ficheroSalida)
{
Graphics2D g = null;
try
{
BufferedImage input = ImageIO.read(new
File(ficheroEntrada));
System.out.println("1.-");
int w = input.getWidth();
int h = input.getHeight();
System.out.println("2.-");
BufferedImage output = new BufferedImage((ancho * w) / w,
(ancho * h) / w, 5);
System.out.println("3.-,,,");
try
{
g = output.createGraphics();
}
catch(Exception ese)
{
ese.printStackTrace();
}
System.out.println("4.-");
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
System.out.println("5.-");
g.drawImage(input, 0, 0, (ancho * w) / w, (ancho * h) / w,
null);
System.out.println("6.-");
ImageIO.write(output, "jpg", new File(ficheroSalida));
System.out.println("7.-");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("ERROR redimensionado imagen: " +
e.getMessage());
}
}
public static void main(String args[])
{
RedimensionamientoDeImagenesJPG f = new
RedimensionamientoDeImagenesJPG();
try
{
f.redimensionaJPG(200, args[0], args[1]);
}
catch(Exception e) { }
}
}
Using the bello code i am trying to resize one image (jpg).
this class is using into one web apllication for resizing jpg images.
in windows it runs well but into my linux i doesn't work.
In linux the program is executed to the:
System.out.println("3.-,,,");
try
{
g = output.createGraphics();
it doesn't continuous where it mades g = output.createGraphics();
if i try to execute into linux from the main, its main method appears
this error:
1.-
2.-
3.-,,,
Exception in thread "main" java.lang.InternalError: Can't connect to
X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:134)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1041)
at RedimensionamientoDeImagenesJPG.redimensionaJPG(RedimensionamientoDeImagenesJPG.java:36)
at RedimensionamientoDeImagenesJPG.main(RedimensionamientoDeImagenesJPG.java:58)
Can you help me to resizing one JSP image?
thanks
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.PrintStream;
import javax.imageio.ImageIO;
public class RedimensionamientoDeImagenesJPG
{
public RedimensionamientoDeImagenesJPG()
{
}
public void redimensionaJPG(int ancho, String ficheroEntrada,
String ficheroSalida)
{
Graphics2D g = null;
try
{
BufferedImage input = ImageIO.read(new
File(ficheroEntrada));
System.out.println("1.-");
int w = input.getWidth();
int h = input.getHeight();
System.out.println("2.-");
BufferedImage output = new BufferedImage((ancho * w) / w,
(ancho * h) / w, 5);
System.out.println("3.-,,,");
try
{
g = output.createGraphics();
}
catch(Exception ese)
{
ese.printStackTrace();
}
System.out.println("4.-");
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
System.out.println("5.-");
g.drawImage(input, 0, 0, (ancho * w) / w, (ancho * h) / w,
null);
System.out.println("6.-");
ImageIO.write(output, "jpg", new File(ficheroSalida));
System.out.println("7.-");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("ERROR redimensionado imagen: " +
e.getMessage());
}
}
public static void main(String args[])
{
RedimensionamientoDeImagenesJPG f = new
RedimensionamientoDeImagenesJPG();
try
{
f.redimensionaJPG(200, args[0], args[1]);
}
catch(Exception e) { }
}
}