Skip to main content
Interwork Corporation
IDR Solutions Product Support Portal
モードの切替 ダーク/ライト/自動 モードの切替 ダーク/ライト/自動 モードの切替 ダーク/ライト/自動

画像のクロップ

機能説明

クロップ操作は、指定された矩形の位置、幅、高さで画像をクロップします。

Javaで画像をクロップする例

ImageProcessingOperations operations = new ImageProcessingOperations();

// You can chain several operations here such as scale, blur, etc
operations.crop(new Rectangle(10, 10, 100, 150)); // crop to a 100x150 rectangle at position 10,10 
        
// Apply the operations to a BufferedImage
BufferedImage modifiedImage = operations.apply(BufferedImage originalImage);

その他のコード例

以下のコード例を使用して、画像フォーマット間で処理・変換を行います:

Fileを使用する場合

File inputFile = new File("path/to/file");
File outputFile = new File("path/to/output-cropped-file");
JDeli.convert(inputFile, outputFile, operations);

InputStreamとOutputSteamを使用する場合

final InputStream inputStream = new FileInputStream(inputFile);
final OutputStream outputStream = new FileOutputStream(outputFile);
final String outputFormat = "format"; // format of the output file eg. png, jpeg,...;
JDeli.convert(inputStream, outputStream, outputFormat, operations);

byte[]を使用する場合

byte[] inputData = Files.readAllBytes(Paths.get("/path/to/file"));
final String outputFormat = "format"; // format of the output file eg. png, jpeg,...;
byte[] outputData = JDeli.convert(inputData, outputFormat, operations);

クロップ操作のJavadocを見る