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.clip(new Arc2D.Double(new Rectangle(0, 0, 100, 100), 0, 360, Arc2D.PIE), true); // Clip the image to a circle
        
// 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-clipped-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を見る