We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

[Aspose.Imaging for Java] 複数スレッドで Image.save を実行すると、たまにエラーが発生する

WMFファイルをJPEGファイルに変換しようとしています。
ファイルの数が多いので、複数のスレッドを並列で動かしています。

ただ、Image.save(OutputStream var1, ImageOptionsBase var2) メソッドで、エラーが発生します。
毎回エラーになるわけではなく、エラーが発生するときと、しないときがあります。

Exception in thread "main" java.util.concurrent.ExecutionException: class com.aspose.imaging.coreexceptions.ImageSaveException: Image export failed. ---> class com.aspose.imaging.internal.Exceptions.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Parameter name: index
com.aspose.imaging.system.collections.Generic.List.removeAt(Unknown Source)
com.aspose.imaging.system.collections.Generic.List.removeItem(Unknown Source)
com.aspose.imaging.internal.aq.x.b(Unknown Source)
com.aspose.imaging.internal.aq.x.a(Unknown Source)
com.aspose.imaging.internal.aq.x$b.dispose(Unknown Source)
com.aspose.imaging.system.io.Stream.close(Unknown Source)
com.aspose.imaging.system.io.Stream.dispose(Unknown Source)
com.aspose.imaging.internal.aq.bQ.g(Unknown Source)
com.aspose.imaging.internal.aq.bQ.dispose(Unknown Source)
com.aspose.imaging.internal.aq.bQ.dispose(Unknown Source)
com.aspose.imaging.StreamContainer.disposeStream(Unknown Source)
com.aspose.imaging.StreamContainer.releaseManagedResources(Unknown Source)
com.aspose.imaging.DisposableObject.c(Unknown Source)
com.aspose.imaging.DisposableObject.dispose(Unknown Source)
com.aspose.imaging.DisposableObject.close(Unknown Source)
com.aspose.imaging.internal.eV.c.releaseManagedResources(Unknown Source)
com.aspose.imaging.DisposableObject.c(Unknown Source)
com.aspose.imaging.DisposableObject.dispose(Unknown Source)
com.aspose.imaging.DisposableObject.close(Unknown Source)
com.aspose.imaging.fileformats.jpeg.a.process(Unknown Source)
com.aspose.imaging.internal.eR.o.process(Unknown Source)
com.aspose.imaging.internal.aq.bc.process(Unknown Source)
com.aspose.imaging.internal.aq.bb.process(Unknown Source)
com.aspose.imaging.internal.aq.bt.process(Unknown Source)
com.aspose.imaging.internal.eQ.d.b(Unknown Source)
com.aspose.imaging.internal.eQ.d.a(Unknown Source)
com.aspose.imaging.internal.eQ.d$b.loadPartialArgb32Pixels(Unknown Source)
com.aspose.imaging.internal.aq.bf.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.eQ.c.loadPartialArgb32Pixels(Unknown Source)
com.aspose.imaging.internal.aq.bf.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.aD.a(Unknown Source)
com.aspose.imaging.RasterImage.a(Unknown Source)
com.aspose.imaging.RasterImage.loadPartialArgb32Pixels(Unknown Source)
com.aspose.imaging.fileformats.jpeg.JpegImage.a(Unknown Source)
com.aspose.imaging.fileformats.jpeg.JpegImage.a(Unknown Source)
com.aspose.imaging.internal.aJ.w.a(Unknown Source)
com.aspose.imaging.internal.aJ.G.a(Unknown Source)
com.aspose.imaging.internal.aJ.t.b(Unknown Source)
com.aspose.imaging.internal.aJ.t.export(Unknown Source)
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.p.a(Unknown Source)
com.aspose.imaging.internal.px.b.a(Unknown Source)
com.aspose.imaging.internal.px.c.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
image.convert.test.TestConverter.convertVectorRasterizationTo(TestConverter.java:87)
image.convert.test.TestConverter.convertWmfTo(TestConverter.java:70)
image.convert.test.TestConverter.lambda$0(TestConverter.java:55)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
   --- End of inner exception stack trace ---
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.p.a(Unknown Source)
com.aspose.imaging.internal.px.b.a(Unknown Source)
com.aspose.imaging.internal.px.c.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
image.convert.test.TestConverter.convertVectorRasterizationTo(TestConverter.java:87)
image.convert.test.TestConverter.convertWmfTo(TestConverter.java:70)
image.convert.test.TestConverter.lambda$0(TestConverter.java:55)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at image.convert.test.TestConverter.convertFiles(TestConverter.java:63)
    at image.convert.test.TestConverter.main(TestConverter.java:33)
Caused by: class com.aspose.imaging.coreexceptions.ImageSaveException: Image export failed. ---> class com.aspose.imaging.internal.Exceptions.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Parameter name: index
com.aspose.imaging.system.collections.Generic.List.removeAt(Unknown Source)
com.aspose.imaging.system.collections.Generic.List.removeItem(Unknown Source)
com.aspose.imaging.internal.aq.x.b(Unknown Source)
com.aspose.imaging.internal.aq.x.a(Unknown Source)
com.aspose.imaging.internal.aq.x$b.dispose(Unknown Source)
com.aspose.imaging.system.io.Stream.close(Unknown Source)
com.aspose.imaging.system.io.Stream.dispose(Unknown Source)
com.aspose.imaging.internal.aq.bQ.g(Unknown Source)
com.aspose.imaging.internal.aq.bQ.dispose(Unknown Source)
com.aspose.imaging.internal.aq.bQ.dispose(Unknown Source)
com.aspose.imaging.StreamContainer.disposeStream(Unknown Source)
com.aspose.imaging.StreamContainer.releaseManagedResources(Unknown Source)
com.aspose.imaging.DisposableObject.c(Unknown Source)
com.aspose.imaging.DisposableObject.dispose(Unknown Source)
com.aspose.imaging.DisposableObject.close(Unknown Source)
com.aspose.imaging.internal.eV.c.releaseManagedResources(Unknown Source)
com.aspose.imaging.DisposableObject.c(Unknown Source)
com.aspose.imaging.DisposableObject.dispose(Unknown Source)
com.aspose.imaging.DisposableObject.close(Unknown Source)
com.aspose.imaging.fileformats.jpeg.a.process(Unknown Source)
com.aspose.imaging.internal.eR.o.process(Unknown Source)
com.aspose.imaging.internal.aq.bc.process(Unknown Source)
com.aspose.imaging.internal.aq.bb.process(Unknown Source)
com.aspose.imaging.internal.aq.bt.process(Unknown Source)
com.aspose.imaging.internal.eQ.d.b(Unknown Source)
com.aspose.imaging.internal.eQ.d.a(Unknown Source)
com.aspose.imaging.internal.eQ.d$b.loadPartialArgb32Pixels(Unknown Source)
com.aspose.imaging.internal.aq.bf.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.eQ.c.loadPartialArgb32Pixels(Unknown Source)
com.aspose.imaging.internal.aq.bf.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.aD.a(Unknown Source)
com.aspose.imaging.RasterImage.a(Unknown Source)
com.aspose.imaging.RasterImage.loadPartialArgb32Pixels(Unknown Source)
com.aspose.imaging.fileformats.jpeg.JpegImage.a(Unknown Source)
com.aspose.imaging.fileformats.jpeg.JpegImage.a(Unknown Source)
com.aspose.imaging.internal.aJ.w.a(Unknown Source)
com.aspose.imaging.internal.aJ.G.a(Unknown Source)
com.aspose.imaging.internal.aJ.t.b(Unknown Source)
com.aspose.imaging.internal.aJ.t.export(Unknown Source)
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.p.a(Unknown Source)
com.aspose.imaging.internal.px.b.a(Unknown Source)
com.aspose.imaging.internal.px.c.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
image.convert.test.TestConverter.convertVectorRasterizationTo(TestConverter.java:87)
image.convert.test.TestConverter.convertWmfTo(TestConverter.java:70)
image.convert.test.TestConverter.lambda$0(TestConverter.java:55)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
   --- End of inner exception stack trace ---
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.p.a(Unknown Source)
com.aspose.imaging.internal.px.b.a(Unknown Source)
com.aspose.imaging.internal.px.c.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
image.convert.test.TestConverter.convertVectorRasterizationTo(TestConverter.java:87)
image.convert.test.TestConverter.convertWmfTo(TestConverter.java:70)
image.convert.test.TestConverter.lambda$0(TestConverter.java:55)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
    at com.aspose.imaging.Image.a(Unknown Source)
    at com.aspose.imaging.p.a(Unknown Source)
    at com.aspose.imaging.internal.px.b.a(Unknown Source)
    at com.aspose.imaging.internal.px.c.a(Unknown Source)
    at com.aspose.imaging.Image.save(Unknown Source)
    at image.convert.test.TestConverter.convertVectorRasterizationTo(TestConverter.java:87)
    at image.convert.test.TestConverter.convertWmfTo(TestConverter.java:70)
    at image.convert.test.TestConverter.lambda$0(TestConverter.java:55)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: class com.aspose.imaging.internal.Exceptions.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Parameter name: index
com.aspose.imaging.system.collections.Generic.List.removeAt(Unknown Source)
com.aspose.imaging.system.collections.Generic.List.removeItem(Unknown Source)
com.aspose.imaging.internal.aq.x.b(Unknown Source)
com.aspose.imaging.internal.aq.x.a(Unknown Source)
com.aspose.imaging.internal.aq.x$b.dispose(Unknown Source)
com.aspose.imaging.system.io.Stream.close(Unknown Source)
com.aspose.imaging.system.io.Stream.dispose(Unknown Source)
com.aspose.imaging.internal.aq.bQ.g(Unknown Source)
com.aspose.imaging.internal.aq.bQ.dispose(Unknown Source)
com.aspose.imaging.internal.aq.bQ.dispose(Unknown Source)
com.aspose.imaging.StreamContainer.disposeStream(Unknown Source)
com.aspose.imaging.StreamContainer.releaseManagedResources(Unknown Source)
com.aspose.imaging.DisposableObject.c(Unknown Source)
com.aspose.imaging.DisposableObject.dispose(Unknown Source)
com.aspose.imaging.DisposableObject.close(Unknown Source)
com.aspose.imaging.internal.eV.c.releaseManagedResources(Unknown Source)
com.aspose.imaging.DisposableObject.c(Unknown Source)
com.aspose.imaging.DisposableObject.dispose(Unknown Source)
com.aspose.imaging.DisposableObject.close(Unknown Source)
com.aspose.imaging.fileformats.jpeg.a.process(Unknown Source)
com.aspose.imaging.internal.eR.o.process(Unknown Source)
com.aspose.imaging.internal.aq.bc.process(Unknown Source)
com.aspose.imaging.internal.aq.bb.process(Unknown Source)
com.aspose.imaging.internal.aq.bt.process(Unknown Source)
com.aspose.imaging.internal.eQ.d.b(Unknown Source)
com.aspose.imaging.internal.eQ.d.a(Unknown Source)
com.aspose.imaging.internal.eQ.d$b.loadPartialArgb32Pixels(Unknown Source)
com.aspose.imaging.internal.aq.bf.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.eQ.c.loadPartialArgb32Pixels(Unknown Source)
com.aspose.imaging.internal.aq.bf.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.bh.a(Unknown Source)
com.aspose.imaging.internal.aq.aD.a(Unknown Source)
com.aspose.imaging.RasterImage.a(Unknown Source)
com.aspose.imaging.RasterImage.loadPartialArgb32Pixels(Unknown Source)
com.aspose.imaging.fileformats.jpeg.JpegImage.a(Unknown Source)
com.aspose.imaging.fileformats.jpeg.JpegImage.a(Unknown Source)
com.aspose.imaging.internal.aJ.w.a(Unknown Source)
com.aspose.imaging.internal.aJ.G.a(Unknown Source)
com.aspose.imaging.internal.aJ.t.b(Unknown Source)
com.aspose.imaging.internal.aJ.t.export(Unknown Source)
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.p.a(Unknown Source)
com.aspose.imaging.internal.px.b.a(Unknown Source)
com.aspose.imaging.internal.px.c.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
image.convert.test.TestConverter.convertVectorRasterizationTo(TestConverter.java:87)
image.convert.test.TestConverter.convertWmfTo(TestConverter.java:70)
image.convert.test.TestConverter.lambda$0(TestConverter.java:55)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
    at com.aspose.imaging.system.collections.Generic.List.removeAt(Unknown Source)
    at com.aspose.imaging.system.collections.Generic.List.removeItem(Unknown Source)
    at com.aspose.imaging.internal.aq.x.b(Unknown Source)
    at com.aspose.imaging.internal.aq.x.a(Unknown Source)
    at com.aspose.imaging.internal.aq.x$b.dispose(Unknown Source)
    at com.aspose.imaging.system.io.Stream.close(Unknown Source)
    at com.aspose.imaging.system.io.Stream.dispose(Unknown Source)
    at com.aspose.imaging.internal.aq.bQ.g(Unknown Source)
    at com.aspose.imaging.internal.aq.bQ.dispose(Unknown Source)
    at com.aspose.imaging.internal.aq.bQ.dispose(Unknown Source)
    at com.aspose.imaging.StreamContainer.disposeStream(Unknown Source)
    at com.aspose.imaging.StreamContainer.releaseManagedResources(Unknown Source)
    at com.aspose.imaging.DisposableObject.c(Unknown Source)
    at com.aspose.imaging.DisposableObject.dispose(Unknown Source)
    at com.aspose.imaging.DisposableObject.close(Unknown Source)
    at com.aspose.imaging.internal.eV.c.releaseManagedResources(Unknown Source)
    at com.aspose.imaging.DisposableObject.c(Unknown Source)
    at com.aspose.imaging.DisposableObject.dispose(Unknown Source)
    at com.aspose.imaging.DisposableObject.close(Unknown Source)
    at com.aspose.imaging.fileformats.jpeg.a.process(Unknown Source)
    at com.aspose.imaging.internal.eR.o.process(Unknown Source)
    at com.aspose.imaging.internal.aq.bc.process(Unknown Source)
    at com.aspose.imaging.internal.aq.bb.process(Unknown Source)
    at com.aspose.imaging.internal.aq.bt.process(Unknown Source)
    at com.aspose.imaging.internal.eQ.d.b(Unknown Source)
    at com.aspose.imaging.internal.eQ.d.a(Unknown Source)
    at com.aspose.imaging.internal.eQ.d$b.loadPartialArgb32Pixels(Unknown Source)
    at com.aspose.imaging.internal.aq.bf.a(Unknown Source)
    at com.aspose.imaging.internal.aq.bh.a(Unknown Source)
    at com.aspose.imaging.internal.aq.bh.a(Unknown Source)
    at com.aspose.imaging.internal.aq.bh.a(Unknown Source)
    at com.aspose.imaging.internal.eQ.c.loadPartialArgb32Pixels(Unknown Source)
    at com.aspose.imaging.internal.aq.bf.a(Unknown Source)
    at com.aspose.imaging.internal.aq.bh.a(Unknown Source)
    at com.aspose.imaging.internal.aq.bh.a(Unknown Source)
    at com.aspose.imaging.internal.aq.bh.a(Unknown Source)
    at com.aspose.imaging.internal.aq.aD.a(Unknown Source)
    at com.aspose.imaging.RasterImage.a(Unknown Source)
    at com.aspose.imaging.RasterImage.loadPartialArgb32Pixels(Unknown Source)
    at com.aspose.imaging.fileformats.jpeg.JpegImage.a(Unknown Source)
    at com.aspose.imaging.fileformats.jpeg.JpegImage.a(Unknown Source)
    at com.aspose.imaging.internal.aJ.w.a(Unknown Source)
    at com.aspose.imaging.internal.aJ.G.a(Unknown Source)
    at com.aspose.imaging.internal.aJ.t.b(Unknown Source)
    at com.aspose.imaging.internal.aJ.t.export(Unknown Source)
    ... 12 more

これはバグでしょうか?
ご確認のほどよろしくお願いいたします。

使用バージョン : Aspose.Imaging for Java 21.7
JavaのHeapサイズ : -Xmx8g
WMFファイル : wmf_files.zip (9.5 MB)

以下が、並列実行しているプログラムです。

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import com.aspose.imaging.Image;
import com.aspose.imaging.ImageOptionsBase;
import com.aspose.imaging.imageoptions.JpegOptions;
import com.aspose.imaging.imageoptions.VectorRasterizationOptions;
import com.aspose.imaging.imageoptions.WmfRasterizationOptions;

public class TestConverter {

    public static void main(String[] args) throws Exception {

        Path inputDirPath = Paths.get("C:\\_parallel_test\\input");
        Path outputDirPath = Paths.get("C:\\_parallel_test\\output");
        int parallelThreadNum = 1;

        // Repeat until error
        while (true) {
            convertFiles(inputDirPath, outputDirPath, parallelThreadNum);

            // If no error, clear output files.
            for (File outputFile : outputDirPath.toFile().listFiles()) {
                Files.delete(outputFile.toPath());
            }
        }
    }

    private static void convertFiles(Path inputDirPath, Path outputDirPath, int threadNum) throws Exception {

        ExecutorService executorService = Executors.newFixedThreadPool(threadNum);
        List<Future<?>> futures = new ArrayList<>();

        List<File> files = Arrays.asList(inputDirPath.toFile().listFiles());
        Collections.shuffle(files);

        for (File inputFile : files) {

            Path outputFilePath = outputDirPath.resolve(inputFile.getName() + ".jpeg");
            Future<?> future = executorService.submit(() -> {

                convertWmfTo(inputFile.toPath(), outputFilePath);
                return null;
            });

            futures.add(future);
        }

        for (Future<?> future : futures) {
            future.get();
        }
    }

    private static void convertWmfTo(Path sourceFilePath, Path outputFilePath) throws IOException {

        try (WmfRasterizationOptions rasterizationOptions = new WmfRasterizationOptions()) {
            convertVectorRasterizationTo(sourceFilePath, outputFilePath, rasterizationOptions);
        }
    }

    private static void convertVectorRasterizationTo(
            Path inputPath, Path outputPath, VectorRasterizationOptions rasterizationOptions)
            throws IOException {

        try (OutputStream outputStream = Files.newOutputStream(outputPath);
                InputStream inputStream = Files.newInputStream(inputPath);
                Image image = Image.load(inputStream);
                ImageOptionsBase options = new JpegOptions();) {

            rasterizationOptions.setPageWidth(500);
            rasterizationOptions.setPageHeight(500);

            options.setVectorRasterizationOptions(rasterizationOptions);
            image.save(outputStream, options);
        }
    }
}

@yudai_yamaguchi

問題をさらに調査して解決するために、問題追跡システムでID IMAGINGJAVA-7888のチケットを作成しました。 しかし、私はこれを自分の側で再現することはできませんでした。 このスレッドは問題にリンクされているため、問題が修正されたら通知を受けることができます。