TIFF (Format Gambar Gambar Tagged) minangka format populer kanggo nyimpen gambar digital kanthi kualitas dhuwur. Uga misuwur amarga bisa nyimpen data gambar luwih akeh tinimbang pasangan JPEG, lan menehi kualitas gambar sing nggumunke. Umume, kompresi lossless tegese file TIFF nahan detail gambar asli lan ambane warna - sampurna kanggo foto profesional sing berkualitas tinggi. Kanthi Aspose.PDF Cloud, sampeyan bisa nggabungake pirang-pirang gambar TIFF dadi file TIFF siji, sing bisa migunani kanggo sawetara aplikasi. Artikel iki bakal nuntun sampeyan ing proses nggabungake gambar TIFF nggunakake Aspose.PDF Cloud API ing Jawa.
API Pangolahan Gambar
Aspose.Imaging Cloud minangka API berbasis awan kanggo nggarap gambar, kalebu gambar TIFF. Nyedhiyakake antarmuka sing gampang digunakake lan nawakake sawetara fitur kanggo nggarap gambar TIFF, kalebu kemampuan kanggo nggabungake pirang-pirang file TIFF dadi file TIFF siji. Nggunakake Aspose.Imaging Cloud SDK for Java, pangembang bisa nyederhanakake proses nggabungake gambar TIFF, amarga bisa nindakake tugas iki ing awan, tanpa kudu nginstal piranti lunak lokal. Saiki, supaya bisa nggunakake kapabilitas ing proyek Java, kita kudu nambah referensi ing proyek java kanthi nyakup informasi ing ngisor iki ing pom.xml (proyek jinis mbangun maven).
<repositories>
<repository>
<id>aspose-cloud</id>
<name>artifact.aspose-cloud-releases</name>
<url>https://artifact.aspose.cloud/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-imaging-cloud</artifactId>
<version>22.4</version>
</dependency>
</dependencies>
Sawise referensi SDK wis ditambahake, entuk kredensial klien pribadi saka Cloud Dashboard. Yen sampeyan ora duwe akun, mangga nggawe akun gratis nggunakake alamat email sing bener.
Gabungke Gambar TIFF ing Jawa
Bagean iki bakal nerangake langkah-langkah kanggo nambah file TIFF nggunakake Java.
- Kaping pisanan, gawe obyek saka ImagingApi, nalika menehi kredensial klien pribadi minangka argumen
- Kapindho, waca isi gambar TIFF pisanan nggunakake metode readAllBytes(…) banjur bali menyang array byte[]
- Katelu, gawe conto kelas UploadFileRequest, ing ngendi kita nemtokake jeneng kanggo gambar TIFF sing bakal diunggah ing panyimpenan Cloud
- Saiki upload gambar TIFF pisanan menyang panyimpenan maya nggunakake metode uploadFile(…).
- Baleni langkah sing padha kanggo maca banjur upload gambar TIFF kapindho menyang panyimpenan Cloud
- Saiki kita kudu nggawe obyek AppendTiffRequest ing ngendi kita nemtokake jeneng gambar TIFF sing bakal digabung
- Miwiti operasi gabungan TIFF nggunakake metode appendTiff(…) saka ImagingAPI
- Amarga gambar asil disimpen ing panyimpenan Cloud, mula kita kudu nggunakake obyek DownloadFileRequest, kanggo ngundhuh gambar TIFF gabungan.
// Entuk ClientID lan ClientSecret saka https://dashboard.aspose.cloud/
String clientId = "7ef10407-c1b7-43bd-9603-5ea9c6db83cd";
String clientSecret = "ba7cc4dc0c0478d7b508dd8ffa029845";
// nggawe obyek Imaging
ImagingApi imageApi = new ImagingApi(clientSecret, clientId);
// mbukak gambar TIFF pisanan saka sistem lokal
File file1 = new File("DeskewSampleImage.tif");
byte[] imageStream = Files.readAllBytes(file1.toPath());
// nggawe obyek panjalukan upload file
UploadFileRequest uploadRequest = new UploadFileRequest("first.tiff",imageStream,null);
// upload gambar TIFF pisanan menyang panyimpenan Cloud
imageApi.uploadFile(uploadRequest);
// mbukak gambar TIFF kapindho saka sistem lokal
File file2 = new File("resultant.tiff");
byte[] imageStream2 = Files.readAllBytes(file2.toPath());
// nggawe obyek panjalukan upload file
UploadFileRequest uploadRequest2 = new UploadFileRequest("second.tiff",imageStream2,null);
// upload gambar TIFF kapindho menyang panyimpenan Cloud
imageApi.uploadFile(uploadRequest2);
// Nggawe panjalukan gabungan Tiff
AppendTiffRequest appendRequest = new AppendTiffRequest("first.tiff","second.tiff",null,null);
// concatenate gambar TIFF lan nyimpen file asil ing panyimpenan Cloud
imageApi.appendTiff(appendRequest);
// Ngundhuh gabungan TIFF menyang panyimpenan lokal
DownloadFileRequest downloadFileRequest = new DownloadFileRequest("first.tiff", null, null);
// maca isi TIFF saka Cloud storage kanggo byte array
byte[] updatedImage = imageApi.downloadFile(downloadFileRequest);
// Simpen gambar sing dianyari menyang panyimpenan lokal
FileOutputStream fos = new FileOutputStream("/Users/s4/Documents/" + "Merged-TIFF.tiff");
fos.write(updatedImage);
fos.close();
Gambar sampel TIFF sing digunakake ing conto ing ndhuwur bisa diundhuh saka DeskewSampleImage.tif lan second.tiff. Gabungan pungkasan TIFF uga bisa diundhuh saka Merged-TIFF.tiff.
Tambah File TIF nggunakake Perintah cURL
Amarga SDK kita dibangun miturut arsitektur REST, sing ndhukung kemampuan independen platform, mula kita bisa ngakses kanthi gampang liwat terminal baris perintah. Saiki bagean iki, bakal nerangake rincian babagan cara nggabungake file TIFF nggunakake perintah cURL.
Langkah pisanan yaiku ngasilake token akses JWT (adhedhasar kredensial klien) nggunakake printah ing ngisor iki.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Sawise token JWT wis digawe, kita kudu nglakokake perintah ing ngisor iki kanggo nggabungake gambar TIFF.
curl -v -X POST "https://api.aspose.cloud/v3.0/imaging/tiff/first.tiff/appendTiff?appendFile=second.tiff" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-o Combined.tiff
Kesimpulan
Kesimpulane, nggabungake gambar TIFF minangka tugas sing gampang ditindakake kanthi nggunakake Aspose.Imaging Cloud SDK kanggo Jawa. Kanthi arsitektur basis awan lan fitur lengkap, Aspose.Imaging Cloud nyedhiyakake cara sing trep lan efisien kanggo nindakake tugas manipulasi gambar, kalebu nggabungake gambar TIFF, tanpa kudu kuwatir babagan ngatur perpustakaan pangolahan gambar utawa prosedur instalasi sing rumit. Apa sampeyan pangembang piranti lunak profesional utawa mung kudu nindakake tugas manipulasi gambar sing prasaja, Aspose.Imaging Cloud nyedhiyakake solusi sing dipercaya lan gampang digunakake kanggo kabeh kabutuhan pangolahan gambar.
Disaranake banget njelajah Dokumentasi Produk, sing ngemot akeh informasi lan ngidini sampeyan sinau fitur API liyane sing nyenengake. Pungkasan, yen sampeyan nemoni masalah nalika nggunakake API, sampeyan bisa nimbang nyedhaki kita kanggo resolusi cepet liwat [forum dhukungan produk] gratis 9.
Artikel sing gegandhengan
Mangga bukak link ing ngisor iki kanggo mangerteni sing luwih lengkap babagan: