TIFF (Tagged Tsarin Fayil na Hoto) sanannen tsari ne don adana hotuna na dijital masu inganci. Hakanan sananne ne saboda yana iya adana bayanan hoto da yawa fiye da takwaransa JPEG, kuma yana ba da ingancin hoto mai ban sha’awa. Galibi, matsawa mara asara yana nufin fayilolin TIFF suna riƙe da ainihin hoton hoton da zurfin launi - cikakke don ƙwararrun hotuna masu inganci. Tare da Aspose.PDF Cloud, yana yiwuwa a haɗa hotuna TIFF da yawa a cikin fayil ɗin TIFF guda ɗaya, wanda zai iya zama da amfani ga aikace-aikace da yawa. Wannan labarin zai jagorance ku ta hanyar haɗa hotunan TIFF ta amfani da Aspose.PDF Cloud API a Java.
API ɗin sarrafa hoto
Aspose.Imaging Cloud API ne na tushen girgije don aiki tare da hotuna, gami da hotunan TIFF. Yana ba da sauƙi mai sauƙi don amfani don kuma yana ba da dama fasali don aiki tare da hotunan TIFF, gami da ikon haɗa fayilolin TIFF da yawa a cikin fayil ɗin TIFF ɗaya. Yin amfani da Aspose.Imaging Cloud SDK for Java, masu haɓakawa na iya sauƙaƙe tsarin haɗa hotunan TIFF, saboda suna iya yin wannan aikin gaba ɗaya a cikin gajimare, ba tare da shigar da kowace software a gida ba. Yanzu, don amfani da damarsa a cikin aikin Java, muna buƙatar ƙara bayaninsa a cikin aikin java ta hanyar haɗa bayanai masu zuwa a cikin pom.xml (maven build type project).
<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>
Da zarar an ƙara nassoshi na SDK, da fatan za a sami keɓaɓɓen bayanan abokin ciniki daga Cloud Dashboard. Idan ba ku da asusu, da fatan za a ƙirƙiri asusun kyauta ta amfani da ingantaccen adireshin imel.
Haɗa Hotunan TIFF a Java
Wannan sashe zai ba da haske kan matakai don saka fayilolin TIFF ta amfani da Java.
- Da farko, ƙirƙiri wani abu na ImagingApi, yayin ƙaddamar da keɓaɓɓen bayanan abokin ciniki a matsayin mahawara
- Abu na biyu, karanta abun cikin hoton TIFF na farko ta amfani da hanyar readAllBytes(…) kuma mayar da shi zuwa tsararrun byte[]
- Na uku, ƙirƙiri misali na ajin UploadFileRequest, inda muka saka sunan hoton TIFF da za a ɗora akan ma’ajiyar gajimare.
- Yanzu loda hoton TIFF na farko zuwa ma’ajiyar gajimare ta amfani da hanyar uploadFile(…).
- Maimaita matakan guda ɗaya don karantawa sannan loda hoton TIFF na biyu zuwa ma’ajiyar girgije
- Yanzu muna buƙatar ƙirƙirar wani abu na AppendTiffRequest inda muka saka sunayen hotunan TIFF don haɗawa.
- Fara aikin haɗin TIFF ta amfani da hanyar appendTiff(…) na ImagingAPI
- Kamar yadda aka adana hoton sakamakon a cikin ma’ajiyar gajimare, don haka muna buƙatar amfani da abin ZazzagewarFileRequest, don zazzage hoton TIFF ɗin da aka haɗe.
// Samu ClientID da ClientSecret daga https://dashboard.aspose.cloud/
String clientId = "7ef10407-c1b7-43bd-9603-5ea9c6db83cd";
String clientSecret = "ba7cc4dc0c0478d7b508dd8ffa029845";
// haifar da Hoto abu
ImagingApi imageApi = new ImagingApi(clientSecret, clientId);
// zazzage hoton TIFF na farko daga tsarin gida
File file1 = new File("DeskewSampleImage.tif");
byte[] imageStream = Files.readAllBytes(file1.toPath());
// ƙirƙiri abin buƙatar loda fayil
UploadFileRequest uploadRequest = new UploadFileRequest("first.tiff",imageStream,null);
// loda hoton TIFF na farko zuwa ma'ajiyar gajimare
imageApi.uploadFile(uploadRequest);
// ɗora hoton TIFF na biyu daga tsarin gida
File file2 = new File("resultant.tiff");
byte[] imageStream2 = Files.readAllBytes(file2.toPath());
// ƙirƙiri abin buƙatar loda fayil
UploadFileRequest uploadRequest2 = new UploadFileRequest("second.tiff",imageStream2,null);
// loda hoton TIFF na biyu zuwa ma'ajiyar gajimare
imageApi.uploadFile(uploadRequest2);
// Ƙirƙiri buƙatar haɗin Tiff
AppendTiffRequest appendRequest = new AppendTiffRequest("first.tiff","second.tiff",null,null);
// haɗa hotuna TIFF da adana fayil ɗin sakamako a cikin ma'ajiyar gajimare
imageApi.appendTiff(appendRequest);
// Zazzage haɗin TIFF zuwa ma'ajiyar gida
DownloadFileRequest downloadFileRequest = new DownloadFileRequest("first.tiff", null, null);
// karanta TIFF abun ciki daga Cloud array zuwa byte array
byte[] updatedImage = imageApi.downloadFile(downloadFileRequest);
// Ajiye sabon hoto zuwa ma'ajiyar gida
FileOutputStream fos = new FileOutputStream("/Users/s4/Documents/" + "Merged-TIFF.tiff");
fos.write(updatedImage);
fos.close();
Ana iya sauke samfurin TIFF Hotunan da aka yi amfani da su a cikin misalin da ke sama daga DeskewSampleImage.tif da second.tiff. Hakanan ana iya saukar da haɗin ƙarshe na TIFF daga Merged-TIFF.tiff.
Saka fayilolin TIF ta amfani da Umarnin CURL
Kamar yadda aka gina SDK ɗin mu bisa ga tsarin gine-gine na REST, wanda ke goyan bayan damar dandamali mai zaman kansa, don haka za mu iya samun damar su cikin sauƙi ta tashar layin umarni. Yanzu wannan sashe, zai bayyana cikakkun bayanai kan yadda ake haɗa fayilolin TIFF ta amfani da umarnin CURL.
Mataki na farko shine samar da alamar samun damar JWT (dangane da shaidar abokin ciniki) ta amfani da umarni mai zuwa.
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"
Da zarar an ƙirƙiri alamar JWT, muna buƙatar aiwatar da umarni mai zuwa don haɗa hotunan 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
Kammalawa
A ƙarshe, haɗa hotunan TIFF aiki ne mai sauƙi wanda za’a iya cika shi cikin sauƙi ta amfani da Aspose.Imaging Cloud SDK don Java. Tare da tsarin gine-ginen girgije da kuma cikakkun tsarin fasali, Aspose.Imaging Cloud yana ba da hanya mai dacewa da inganci don aiwatar da ayyukan magudin hoto, ciki har da hada hotuna na TIFF, ba tare da damuwa game da sarrafa ɗakunan karatu masu rikitarwa ko hanyoyin shigarwa ba. Ko kai ƙwararren mai haɓaka software ne ko kuma kawai kuna buƙatar yin aikin sarrafa hoto mai sauƙi, Aspose.Imaging Cloud yana ba da ingantaccen bayani kuma mai sauƙin amfani don duk buƙatun sarrafa hoto.
Muna ba da shawarar sosai bincika Takardun Samfura, wanda ya ƙunshi ɗimbin bayanai kuma yana ba ku damar koyon wasu fasaloli masu ban sha’awa na API. A ƙarshe, idan kun haɗu da kowace matsala yayin amfani da API, kuna iya la’akari da kusantar mu don ƙuduri mai sauri ta hanyar dandalin tallafin samfur 9.
Labarai masu alaka
Da fatan za a ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da: