Yawancin hotunan raster da muke karɓa don aiki & amfani na sirri hotuna ne da aka bincika ko dai ta hanyar na’urar daukar hotan takardu ko ƙila hoto ne daga na’urar hannu. Don haka akwai yuwuwar cewa rubutun da ke cikin hoto bai daidaita daidai ba kuma yana gudana a gefen gefen shafi ko dai a kwance ko a tsaye. A cikin kalmomi masu sauƙi, hotunan da aka bincika galibi ana karkatar da su (takardar an motsa/juya) akan na’urar daukar hotan takardu. Yanzu don magance irin waɗannan batutuwa, mun zaɓi wata dabara mai suna deskewing wacce hanya ce ta yadda ake cire skew ta hanyar jujjuya hoto daidai da skew amma a gaba. Siffar Deskew tana da matuƙar amfani wajen sarrafa hoto ta atomatik, lokacin da hotunan suka fito daga na’urar daukar hotan takardu.
Yanzu a cikin wannan labarin, muna duban cikakkun bayanai kan yadda ake Deskew hoto ta amfani da Java Cloud SDK. Don haka aikin deskew yana aiki a matakai biyu watau gano kusurwar skew na hoton sannan ya juya hoton don gyara skew. Za mu iya yin amfani da wannan aiki akan fax ɗin da aka karɓa da kuma amfani da bayanin (rubutu) akan hoton, ƙididdige kusurwar juyawa, ba iyakokin takarda ba kuma cika abin da ake bukata. Koyaya, mun fahimci cewa ana iya aiwatar da aikin deskew akan hotuna masu launi 1 bit, 8 bit, da 24 bit.
API ɗin Deskew Hoton
Domin tallafawa hoto Muna da API na tushen REST yana ba da damar sarrafa fayil ɗin hotuna a cikin gajimare. Yanzu don aikace-aikacen Java, mun haɓaka musamman Aspose.Imaging Cloud SDK don Java wanda ke ba ku damar aiwatar da damar sarrafa hoto ta hanyar lambar Java. Yanzu domin Deskew hotuna ta amfani da Java girgije SDK, mataki na farko shi ne don ƙara bayaninsa a cikin aikin java ta hada 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 takaddun 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.
Deskew Hoton Kan layi ta amfani da Java
Bari mu bincika cikakkun bayanai kan yadda ake deskew hoto ta amfani da snippet code na Java. Don wannan misalin, muna loda hoton TIFF daga faifan gida kuma muna amfani da aikin hoto na deskew. Ana ajiye sakamakon fayil ɗin zuwa ma’ajiyar gajimare.
- Da farko, ƙirƙiri wani abu na ImagingApi dangane da keɓaɓɓen shaidar abokin ciniki
- Na biyu, ƙirƙiri madaidaicin boolean wanda ke nuna don sake girman hoton daidai gwargwado
- Yanzu karanta abun ciki na tushen TIFF ta amfani da hanyar readAllBytes(…) kuma wuce zuwa byte[] tsararru.
- Mataki na gaba shine ƙirƙirar misali na CreateDeskewedImageRequest wanda ke buƙatar tsararrun Byte, madaidaicin zaɓi don launi na bango da sunan sakamakon deskew hoto.
- A ƙarshe, kira hanyar ƙirƙirarDeskewedImage(…) don deskew hoto. Sakamakon TIFF ana adana shi a cikin ajiyar girgije
// 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);
// saita m don daidaita girman hoton da aka ɗora daidai gwargwado
boolean resizeProportionally = true;
// bayanan launi na baya
String bkColor = "white";
// loda fayil daga rumbun gida
File f = new File("DeskewSampleImage.tiff");
// karanta abun ciki na hoton TIFF zuwa tsararrun byte
byte[] inputStream = Files.readAllBytes(f.toPath());
// ƙirƙirar abu don ayyana kaddarorin hoton deskew
CreateDeskewedImageRequest request = new CreateDeskewedImageRequest(inputStream,resizeProportionally,bkColor,"Resultant.tiff",null);
// Deskew hoto da ajiye fitarwa a cikin ma'ajin gajimare
imageApi.createDeskewedImage(request);
Yanzu idan kuna son adana sakamakon TIFF akan faifan gida/cibiyar sadarwa, to da fatan za a gwada amfani da snippet code mai zuwa.
// 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);
// saita m don daidaita girman hoton da aka ɗora daidai gwargwado
boolean resizeProportionally = true;
// bayanan launi na baya
String bkColor = "white";
// loda fayil daga rumbun gida
File f = new File("DeskewSampleImage.tif");
// karanta abun ciki na hoton TIFF zuwa tsararrun byte
byte[] inputStream = Files.readAllBytes(f.toPath());
// ƙirƙirar abu don ayyana kaddarorin hoton deskew
CreateDeskewedImageRequest request = new CreateDeskewedImageRequest(inputStream,resizeProportionally,bkColor,null,null);
// Deskew hoto da mayar da fitarwa azaman abin rafi
byte[] updatedImage = imageApi.createDeskewedImage(request);
// hanyar da za a adana hoton TIFF da aka ɗaukaka
Path path = Paths.get("/Users/nayyer/Documents/", "DeskewSampleImage_out.tif").toAbsolutePath();
// kira API don deskew hoto da ajiyewa zuwa tuƙi na gida
Files.write(path, updatedImage);
Hoton TIFF da aka yi amfani da shi a sama misali za a iya sauke shi daga DeskewSampleImage.tif.
Deskew PDF ta amfani da Umarnin CURL
Za mu iya karɓar fayil ɗin PDF mai ɗauke da hotuna marasa tushe don haka mafita ɗaya mai sauri ita ce cire hotuna daga fayil ɗin PDF sannan a cire hotunan. Yanzu don cim ma wannan buƙatu, za mu yi amfani da APIs Cloud guda biyu a nan watau Aspose.PDF Cloud don cire hotuna daga fayil ɗin PDF da Aspose.Imaging Cloud zuwa deskew hotuna. Koyaya, kafin mu yi kowane aiki, da farko muna buƙatar fara samar da alamar samun damar JWT (bisa ga shaidar abokin ciniki) ta amfani da bin umarni.
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 muna da alamar JWT, muna buƙatar cire hotunan PDF ta amfani da GreyscaleImage API na Aspose.PDF Cloud. Ana fitar da hotunan a tsarin TIFF kuma ana adana su a cikin ma’ajin gajimare.
curl -v -X PUT "https://api.aspose.cloud/v3.0/pdf/Resultant.pdf/pages/1/images/extract/tiff?width=0&height=0" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
Yanzu da aka fitar da hotuna daga fayil ɗin PDF azaman tsarin TIFF, yanzu muna buƙatar kiran DeskewImage API na Aspose.Imaging Cloud to deskew image. Tunda an dawo da fayil ɗin sakamakon a cikin rafin amsawa, don haka za mu iya ajiye shi zuwa firinta na gida.
curl -v -X GET "https://api.aspose.cloud/v3.0/imaging/image1.tiff/deskew?resizeProportionally=true&bkColor=White" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-o Deskewed.tiff
Kammalawa
A wannan lokacin, mun koyi wasu matakai masu ban mamaki da sauƙi don deskew hoto da kuma deskew PDF ta amfani da Cloud SDK Java. Don haka yanzu za mu iya cim ma buƙatunmu ta amfani da snippet code na Java ko amfani da umarnin CURL. A lokaci guda, muna ƙarfafa ku sosai don bincika Takardun Samfura don ƙarin koyo game da wasu abubuwan ban sha’awa waɗanda API ɗin ke bayarwa.
Lura cewa duk Cloud SDK ɗin mu an haɓaka su ƙarƙashin lasisin MIT don haka za a iya sauke cikakkiyar lambar tushe daga GitHub. A ƙarshe, idan kun gano kowace matsala yayin amfani da API, kuna iya yin la’akari da kusantar mu don ƙuduri mai sauri ta hanyar dandalin tallafi na kyauta 9.
Labarai masu alaka
Da fatan za a ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da: