The list of methods to do Image Resize are organized into topic(s).
double[]
getResize(Image image, Dimension windowSize) get Resize
double w = image.getWidth(null);
double h = image.getHeight(null);
double f = 1;
double fw = w / windowSize.getWidth();
double fh = h / windowSize.getHeight();
if (fw > 1 || fh > 1) {
if (fh > fw) {
w /= fh;
...
BufferedImage
getResizedImage(Image originalImage, Dimension newSize) Get a resized image.
BufferedImage bImage = new BufferedImage(newSize.width, newSize.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = bImage.createGraphics();
g2d.drawImage(originalImage, null, null);
g2d.dispose();
return bImage;
Image
resize(Image img, int newWidth, float quality) resize
if (quality < 0 || quality > 1) {
throw new IllegalArgumentException("Quality has to be between 0 and 1");
ImageIcon ii = new ImageIcon(img);
Image i = ii.getImage();
Image resizedImage = null;
int iWidth = i.getWidth(null);
int iHeight = i.getHeight(null);
...
void
resize(String srcImageFile, String result, int newWidth, float quality) resize
File originalFile = new File(srcImageFile);
if (quality > 1) {
throw new IllegalArgumentException("Quality has to be between 0 and 1");
ImageIcon ii = new ImageIcon(originalFile.getCanonicalPath());
Image i = ii.getImage();
Image resizedImage = null;
int iWidth = i.getWidth(null);
...
ImageIcon
resizeImage(ImageIcon tmpIcon) resize Image
if (tmpIcon != null) {
if (tmpIcon.getIconWidth() > 90) {
tmpIcon = new ImageIcon(tmpIcon.getImage().getScaledInstance(100, -1, Image.SCALE_DEFAULT));
return tmpIcon;
ImageIcon
resizeImage(String imagePath, int width, int height) Method to resize and visualize the user selected image within the image label
ImageIcon ic = new ImageIcon(imagePath);
Image img = ic.getImage();
Image newImage = img.getScaledInstance(width, height, Image.SCALE_SMOOTH);
return new ImageIcon(newImage);