use of javax.imageio.stream.FileImageInputStream in project skin-composer by raeleus.
the class Utils method doesImageFitBox.
public static boolean doesImageFitBox(FileHandle fileHandle, float width, float height) {
boolean result = false;
String suffix = fileHandle.extension();
Iterator<ImageReader> iter = ImageIO.getImageReadersBySuffix(suffix);
if (iter.hasNext()) {
ImageReader reader = iter.next();
try {
ImageInputStream stream = new FileImageInputStream(fileHandle.file());
reader.setInput(stream);
int imageWidth = reader.getWidth(reader.getMinIndex());
int imageHeight = reader.getHeight(reader.getMinIndex());
result = imageWidth < width && imageHeight < height;
} catch (IOException e) {
Gdx.app.error(Utils.class.getName(), "error checking image dimensions", e);
} finally {
reader.dispose();
}
} else {
Gdx.app.error(Utils.class.getName(), "No reader available to check image dimensions");
}
return result;
}
use of javax.imageio.stream.FileImageInputStream in project openj9 by eclipse.
the class VMDataFactory method getStructureDataFromFile.
private static ImageInputStream getStructureDataFromFile(String fileName, IProcess addressSpace) throws IOException {
File blobFile = new File(fileName);
ImageInputStream iis = new FileImageInputStream(blobFile);
iis.setByteOrder(addressSpace.getByteOrder());
return iis;
}
use of javax.imageio.stream.FileImageInputStream in project openj9 by eclipse.
the class FileSniffer method isZipFile.
public static boolean isZipFile(File file) throws IOException {
FileImageInputStream fis = new FileImageInputStream(file);
boolean result = isZipFile(fis);
fis.close();
return result;
}
use of javax.imageio.stream.FileImageInputStream in project OpenOLAT by OpenOLAT.
the class ImageHelperImpl method scaleImage.
/**
* @param image The image to scale
* @param imageExt The extension if not given by the image file (optional)
* @param scaledImaged the new scaled image
* @param maxWidth the maximum width of the new scaled image
* @param maxheight the maximum height of the new scaled image
* @return
*/
@Override
public Size scaleImage(File image, String imageExt, File scaledImage, int maxWidth, int maxHeight, boolean fill) {
ImageInputStream imageSrc = null;
try {
imageSrc = new FileImageInputStream(image);
SizeAndBufferedImage scaledSize = calcScaledSize(imageSrc, imageExt, maxWidth, maxHeight, fill);
if (scaledSize == null || scaledSize.image == null) {
return null;
}
if (!scaledSize.getScaledSize().isChanged() && isSameFormat(image, imageExt, scaledImage)) {
if (FileUtils.copyFileToFile(image, scaledImage, false)) {
return scaledSize.getSize();
}
}
BufferedImage bufferedImage = scaledSize.image;
BufferedImage scaledBufferedImage = scaleTo(bufferedImage, scaledSize.getScaledSize());
if (writeTo(scaledBufferedImage, scaledImage, scaledSize.getScaledSize(), getImageFormat(scaledImage))) {
return scaledSize.getScaledSize();
}
return null;
} catch (IOException e) {
return null;
// fxdiff FXOLAT-109: prevent red screen if the image has wrong EXIF data
} catch (CMMException e) {
return null;
} finally {
closeQuietly(imageSrc);
}
}
use of javax.imageio.stream.FileImageInputStream in project OpenOLAT by OpenOLAT.
the class ImageHelperImpl method cropImage.
@Override
public boolean cropImage(File image, File cropedImage, Crop cropSelection) {
try (ImageInputStream imageSrc = new FileImageInputStream(image)) {
String extension = FileUtils.getFileSuffix(cropedImage.getName());
SizeAndBufferedImage img = getImage(imageSrc, extension);
if (img != null) {
BufferedImage croppedImg = cropTo(img.getImage(), img.getSize(), cropSelection);
Size size = new Size(cropSelection.getWidth(), cropSelection.getHeight(), false);
return writeTo(croppedImg, cropedImage, size, extension);
}
return false;
} catch (IOException e) {
return false;
} catch (CMMException e) {
// if the image has wrong EXIF data
return false;
}
}
Aggregations