Kompres JPG ing Java SDK

Ngurangi ukuran JPG nggunakake Java

Nggunakake REST API ing Java, pangembang bisa ngompres JPG kanthi program. Kanthi solusi sing diwenehake, output bakal dadi file berkualitas tinggi sawise kompresi.

Ndeleng potongan kode

Compress JPG ing Java

Nggunakake Java API sing kuat, pangembang bisa ngompres JPG kanggo ngoptimalake isi lan ukuran file output. Ngurangi ukuran file dumadi kanthi ngresiki data lan sumber daya sing ora digunakake. Sampeyan uga bisa compress gambar kanggo nggawe ukuran file output malah luwih cilik.

Asil optimasi lan kompresi isi bisa disimpen ing JPG asli utawa format nyimpen sing kasedhiya - DOCX, DOC, RTF, PDF, HTML lan liya-liyane.

Ngurangi ukuran JPG file ing Java

Kaya sing wis kasebut, SDK Java kita ngidini sampeyan nyuda ukuran JPG kanthi program. Lan saiki sampeyan bisa nyoba fungsi sing kuat lan ngevaluasi cara ngompres JPG ing Java kanthi conto ing ngisor iki:

Unggah file sing pengin dioptimalake / kompres
Kode roto
Pilih format target saka dhaptar
import com.aspose.words.cloud.*;

ApiClient apiClient = new ApiClient("####-####-####-####-####", "##################", null);
WordsApi wordsApi = new WordsApi(apiClient);

byte[] requestDocument = Files.readAllBytes(Paths.get("Input.jpg").toAbsolutePath());
CompressOptions requestCompressOptions = new CompressOptions();
requestCompressOptions.setImagesQuality(75);
requestCompressOptions.setImagesReduceSizeFactor(1);

CompressDocumentOnlineRequest compressDocumentRequest = new CompressDocumentOnlineRequest(
   requestDocument, requestCompressOptions, null, null, null, null);
CompressDocumentOnline compressDocument =
   wordsApi.compressDocumentOnline(compressDocumentRequest);

ConvertDocumentRequest convertDocument = new ConvertDocumentRequest(
   compressDocument.getDocument().iterator().next(), "jpg", null, null, null, null);
wordsApi.convertDocument(convertDocument);
Kode roto
  
Nyalin kode Java menyang clipboard

Carane ngompres JPG ing Java

  1. Pasang Aspose.Words Cloud for Java
  2. Tambah referensi perpustakaan (ngimpor perpustakaan) menyang proyek Java sampeyan
  3. Konfigurasi API nggunakake tombol app
  4. Muat sumber JPG kanggo ngompres
  5. Kompres JPG, ngresiki informasi sing ora digunakake
  6. Pilih format file output
  7. Entuk asil kompresi JPG minangka file sing kapisah

Pustaka Java kanggo nggunakake kompresi JPG.

Instal 'Aspose.Words Cloud SDK for Java' nggunakake alat otomatisasi mbangun Maven.

Tambah ketergantungan iki menyang POM proyek sampeyan: aspose-cloud artifact.aspose-cloud-releases http://artifact.aspose.cloud/repo com.aspose aspose-words-cloud 22.4.0

Minangka alternatif, sampeyan bisa clone Aspose.Words Cloud SDK for Java saka GitHub lan nggunakake ing project. Tututi Instructions iki supaya cepet entuk kredensial keamanan sing dibutuhake lan ngakses REST API kita.

Requirements Sistem

Deleng Repository Documentation kanggo ndeleng rincian.

Format file liyane sing didhukung

Sampeyan bisa nindakake kompresi dokumen kanggo format file liyane:

5%

Langganan kanggo Aspose Update Product

Entuk buletin saben wulan lan tawaran langsung dikirim menyang kothak layang.

© Aspose Pty Ltd 2001-2024. Kabeh hak dilindhungi undhang-undhang.