yadda ake cire hoton tiff

Yadda ake cire hotuna daga fayilolin TIFF

TIFF na TIF taƙaitaccen tsari ne don Tsarin Fayil ɗin Hoto kuma yana cikin shahararrun hotunan raster, masu zane-zane, masana’antar bugawa, da masu daukar hoto ke amfani da su sosai. TIFF ta bambanta da JPEG, GIF, da PNG saboda tsarin “marasa nauyi” kuma yana iya adana bayanan hoto fiye da takwarorinsu na JPEG. Yanzu ɗayan fitattun fasalulluka na fayilolin TIFF shine ikonsa na adana hotuna da yawa (kowanne yana da tashoshi da yawa) azaman firam ɗin jeri a cikin tari na lokaci ko z-tari na hotuna. Don haka a cikin wannan labarin, za mu bincika cikakkun bayanai kan yadda ake fitar da firam daga hotunan TIFF masu yawa ta amfani da Java Cloud SDK.

API ɗin Tsarin Hoto TIFF

Mun ƙirƙiri API ɗin sarrafa hoto yana ba da damar yin gyara, sarrafa da canza raster, metafiles, Photoshop da sauran Tsarin Tallafawa zuwa tsarin fayil iri-iri. Yanzu magana game da magudin hoton TIFF, API ɗin yana da ikon sarrafa hotunan TIFF. Don haka gwargwadon iyawar wannan labarin, za mu yi amfani da Aspose.Imaging Cloud SDK for Java wanda shine abin rufewa a kusa da REST API. Don haka mataki na farko na amfani da damarsa shine ƙara bayaninsa a cikin aikin java ta haɗa da bin bayanai 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>

Mataki na gaba shine samun cikakkun bayanan shaidar abokin ciniki daga Cloud Dashboard kuma idan baku da asusu akan Aspose Cloud Dashboard, da fatan za a ƙirƙiri asusun kyauta ta hanyar adireshin imel mai inganci. Yanzu shiga ta amfani da sabon asusun da aka ƙirƙira kuma bincika/ƙirƙiri ID na abokin ciniki da Sirrin Abokin ciniki a Aspose Cloud Dashboard.

Yadda ake Cire Hoton TIFF a Java

Bari mu bincika cikakkun bayanai kan yadda ake cire hotuna daga fayilolin tiff ta amfani da snippet code na Java. Da fatan za a lura cewa API ɗin kuma yana ba ku damar sake girma, shuka da juya jujjuya firam ɗin da aka ciro. Haka kuma, ɗayan sigar boolean tana adanaOtherFrames zai baka damar tantance ko sakamakon zai haɗa da duk wasu firam ɗin ko ƙayyadadden firam.

  • Da farko, ƙirƙiri wani abu na ImagingApi dangane da keɓaɓɓen shaidar abokin ciniki
  • Na biyu, karanta abun cikin hoton TIFF na farko ta amfani da hanyar readAllBytes(…) kuma wuce zuwa byte[] tsararru.
  • Na uku, ƙirƙirar misali na UploadFileRequest class inda muka ƙididdige sunan TIFF akan ma’ajiyar gajimare.
  • Yanzu loda hoton TIFF na farko zuwa ma’ajiyar gajimare ta amfani da hanyar uploadFile(…).
  • Mataki na gaba shine tantance firam ɗin TIFF, tsayi & faɗin firam ɗin da aka fitar, asalin hakar kuma saka idan kuna son firam ɗin da aka cire musamman mala’ika.
  • Yanzu ƙirƙiri wani abu na GetImageFrameRequest inda muka saka hoton TIFF shigarwa da ƙayyadaddun kaddarorin sama
  • Kira hanyar samunImageFrame(…) na ImagingAPI don samun firam ɗin TIFF
  • Ajiye firam ɗin da aka fitar zuwa faifan gida ta amfani da abu FileOutputStream
// 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("input.tiff",imageStream,null);
// loda hoton TIFF na farko zuwa ma'ajiyar gajimare
imageApi.uploadFile(uploadRequest);

Integer frameId = 0; // Frame number inside TIFF
// sabon nisa & tsayin firam ɗin da aka fitar
Integer newWidth = 1000;
Integer newHeight = 1400;

// asalin don fara hakar firam
Integer x = 10;
Integer y = 10;

// yanki rectangular don cire firam
Integer rectWidth = 900;
Integer rectHeight = 800;

// Ƙayyade kusurwar juyawa don firam ɗin TIFF da aka fitar
String rotateFlipMethod = "Rotate90FlipY";
// Sakamakon haɗa ƙayyadadden firam kawai ba wasu firam ɗin ba
Boolean saveOtherFrames = false;

// Ƙirƙiri abin nema don fitar da firam ɗin tiff dangane da takamaiman bayanai
GetImageFrameRequest getImageFrameRequest = new GetImageFrameRequest("input.tiff", frameId, newWidth, newHeight,
                    x, y, rectWidth, rectHeight, null, saveOtherFrames, null, null);

// Ana mayar da firam ɗin da aka fitar a cikin rafin amsawa
byte[] updatedImage = imageApi.getImageFrame(getImageFrameRequest);

// Ajiye firam ɗin TIFF da aka fitar akan ma'ajiyar gida
FileOutputStream fos = new FileOutputStream("/Users/s4/Documents/" + "Extracted-TIFF.tiff");
fos.write(updatedImage);
fos.close();
cire tiff frame

Samu Tiff Frames Preview

Ana iya sauke samfurin TIFF hotuna da aka yi amfani da su a cikin misalin sama daga DeskewSampleImage.tif.

Ayyukan TIFF Hoto ta amfani da Umarnin CURL

Wata hanyar da ta dace ta samun damar APIs REST ita ce ta umarnin cURL. Tun da Aspose.Imaging Cloud ya dogara ne akan gine-gine na REST, don haka za mu iya fitar da firam ɗin tiff ta amfani da umarnin cURL. Yanzu abin da ake bukata na wannan aikin 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"

Bayan ƙarni na alamar JWT, muna buƙatar aiwatar da umarni mai zuwa don cire firam ɗin hotunan TIFF.

curl -v -X GET "https://api.aspose.cloud/v3.0/imaging/first.tiff/frames/0?newWidth=1000&newHeight=1200&x=10&y=10&rectWidth=800&rectHeight=800&saveOtherFrames=false" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-o ExtractedFrame.tiff

Kammalawa

A wannan gaba, mun koyi duk mahimman bayanai kan yadda ake cire hotuna daga fayilolin tiff. Mun bincika zaɓi don cire firam ɗin TIFF ta amfani da snippet code Java ko ta umarnin cURL. Wata hanya don gwada fasalulluka masu ban sha’awa na API ita ce ta SwaggerUI kuma idan kuna son canza lambar tushe na SDK, zaku iya zazzagewa idan daga GitHub (duk Cloud SDKs an haɓaka su a ƙarƙashin MIT). lasisi).

Duk da haka, Takardun Samfura tushen bayanai ne mai ban mamaki don koyo game da wasu abubuwan ban sha’awa waɗanda API ɗin ke bayarwa A ƙarshe, idan kun gano wasu batutuwa yayin amfani da API, kuna iya la’akari da kusantar mu don ƙuduri mai sauri ta hanyar kyauta. Tallafin tallafin samfur.

Labarai masu alaka

Da fatan za a ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da: