निम्नलिखित सुविधाओं का उपयोग करके वेबसाइटों की संपूर्ण छवि स्क्रीनशॉट बनाएं या HTML को सीधे छवियों में बदलें GrabzIt के जावा एपीआई। हालांकि इससे पहले कि आप याद रखें कि कॉल करने के बाद URLToImage, HTMLToImage or FileToImage तरीके Save or SaveTo स्क्रीनशॉट लेने के लिए विधि को बुलाया जाना चाहिए।
वेब पेज का स्क्रीनशॉट लेने के लिए या बस एक पैरामीटर की आवश्यकता होती है HTML कन्वर्ट intओ एक छवि फ़ाइल। जैसा कि निम्नलिखित उदाहरण में दिखाया गया है।
grabzIt.URLToImage("https://www.tesla.com"); //Then call the Save or SaveTo method
grabzIt.HTMLToImage("<html><body><h1>Hello World!</h1></body></html>"); //Then call the Save or SaveTo method
grabzIt.FileToImage("example.html"); //Then call the Save or SaveTo method
GrabzIt के जावा एपीआई कई प्रारूपों में इमेज स्क्रीनशॉट ले सकते हैं, जिनमें JPG, PNG, WEBP, BMP (8 बिट, 16 बिट, 24 बिट या 32 बिट) और TIFF शामिल हैं। छवि स्क्रीनशॉट के लिए डिफ़ॉल्ट प्रारूप JPG है। हालाँकि, इन परिस्थितियों में कुछ ऐप्स के लिए JPEG छवि की गुणवत्ता काफी अच्छी नहीं हो सकती है क्योंकि छवि स्क्रीनशॉट के लिए PNG प्रारूप की सिफारिश की जाती है क्योंकि यह गुणवत्ता और फ़ाइल आकार के बीच एक अच्छा संतुलन देता है। नीचे दिए गए उदाहरण में पीएनजी प्रारूप का उपयोग करके एक छवि स्क्रीनशॉट लिया जा रहा है।
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setFormat(ImageFormat.PNG); grabzIt.URLToImage("https://www.tesla.com", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.png");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setFormat(ImageFormat.PNG); grabzIt.HTMLToImage("<html><body><h1>Hello World!</h1></body></html>", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.png");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setFormat(ImageFormat.PNG); grabzIt.FileToImage("example.html", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.png");
ब्राउज़र आकार ब्राउज़र विंडो के आकार को संदर्भित करता है जो कि स्क्रीनशॉट को कैप्चर करते समय उपयोग किया जाएगा अधिकांश मामलों में इसे सेट करने की आवश्यकता नहीं है क्योंकि डिफ़ॉल्ट ब्राउज़र का आकार लगभग सभी कार्यों के लिए पर्याप्त होगा। ब्राउज़र आकार सेट करने के लिए बस एक मान पास करें setBrowserWidth
और setBrowserHeight
के तरीके ImageOptions वर्ग.
एक छवि का आकार बदलना आसान है, छवि को विकृत किए बिना करना थोड़ा कठिन है। पूरी प्रक्रिया को सरल बनाने के लिए हम आपको इसका उपयोग करने की सलाह देते हैं सरल छवि आयाम कैलकुलेटर.
यदि आप ब्राउज़र की चौड़ाई और ऊँचाई की तुलना में छवि की चौड़ाई और ऊँचाई को बड़े आकार में बढ़ाना चाहते हैं, जो डिफ़ॉल्ट रूप से 1366 पिक्सेल द्वारा 728 है, तो ब्राउज़र की चौड़ाई और ऊँचाई को भी मिलान के लिए बढ़ाना होगा।
आप एक कस्टम पहचानकर्ता को पास कर सकते हैं की छवि नीचे दिखाए गए तरीके, यह मान तब आपके GrabzIt Java हैंडलर को वापस कर दिया जाता है। उदाहरण के लिए यह कस्टम पहचानकर्ता एक डेटाबेस पहचानकर्ता हो सकता है, जो स्क्रीनशॉट को किसी विशेष डेटाबेस रिकॉर्ड से जुड़ा होने की अनुमति देता है।
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setCustomId("123456"); grabzIt.URLToImage("https://www.tesla.com", options); //Then call the Save method grabzIt.Save("http://www.example.com/handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setCustomId("123456"); grabzIt.HTMLToImage("<html><body><h1>Hello World!</h1></body></html>", options); //Then call the Save method grabzIt.Save("http://www.example.com/handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setCustomId("123456"); grabzIt.FileToImage("example.html", options); //Then call the Save method grabzIt.Save("http://www.example.com/handler");
GrabzIt आपको एक संपूर्ण वेब पेज की पूरी लंबाई का स्क्रीनशॉट लेने की अनुमति देता है ऐसा करने के लिए आपको एक -1 पास करना होगा setBrowserHeight
तरीका। यह सुनिश्चित करने के लिए कि छवि ब्राउज़र के आकार से मेल खाती है, यह एक -1 पास है setHeight
और setWidth
तरीकों.
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setBrowserHeight(-1); options.setWidth(-1); options.setHeight(-1); grabzIt.URLToImage("https://www.tesla.com", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.jpg");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setBrowserHeight(-1); options.setWidth(-1); options.setHeight(-1); grabzIt.HTMLToImage("<html><body><h1>Hello World!</h1></body></html>", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.jpg");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setBrowserHeight(-1); options.setWidth(-1); options.setHeight(-1); grabzIt.FileToImage("example.html", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.jpg");
आप उन थंबनेल को भी वापस कर सकते हैं जो क्रॉप नहीं हैं, लेकिन सावधान रहें इससे बड़ी छवियां बन सकती हैं। ऐसा करने के लिए -1 को पास करें setHeight
और / या setWidth
तरीकों। कोई भी आयाम जो एक -1 पास होता है, उसे क्रॉप नहीं किया जाएगा।
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setWidth(-1); options.setHeight(-1); grabzIt.URLToImage("https://www.tesla.com", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.jpg");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setWidth(-1); options.setHeight(-1); grabzIt.HTMLToImage("<html><body><h1>Hello World!</h1></body></html>", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.jpg");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setWidth(-1); options.setHeight(-1); grabzIt.FileToImage("example.html", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.jpg");
इन विशेष मानों का उपयोग करने का मतलब है कि आप एक स्क्रीनशॉट बना सकते हैं जो यदि आप चाहें तो पूरे वेब पेज का एक पूर्ण पैमाने पर संस्करण है!
GrabzIt आपको किसी भी HTML तत्व का स्क्रीनशॉट लेने की अनुमति देता है जब तक कि उसके पास एक आईडी या क्लास विशेषता है, जैसे कि ए div
or span
टैग करें, और उसकी सभी सामग्री को कैप्चर करें। ऐसा करने के लिए कि आप जिस HTML एलिमेंट को स्क्रीनशॉट लेना चाहते हैं, उसे एक के रूप में निर्दिष्ट किया जाना चाहिए सीएसएस चयनकर्ता.
... <div id="features"> <img src="http://www.example.com/football.jpg"/><h3>Local Team Loses</h3> </div> ...
नीचे दिए गए उदाहरण में आईडी "फीचर्स" के साथ div पर कब्जा कर लिया गया है और 250 x 250px JPEG छवि के रूप में आउटपुट है।
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); // The 250 parameters indicates that image should be sized to 250 x 250 px ImageOptions options = new ImageOptions(); options.setWidth(250); options.setHeight(250); options.setFormat(ImageFormat.JPG); options.setTargetElement("#features"); grabzIt.URLToImage("http://www.bbc.co.uk/news", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.jpg");
अगला उदाहरण फिर से "फीचर्स" डिव को कैप्चर करता है लेकिन इस बार जेपीईजी इमेज को आउटपुट करता है जो डिव का एक ही आकार है।
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); // The -1 indicates that image should not be cropped ImageOptions options = new ImageOptions(); options.setWidth(-1); options.setHeight(-1); options.setBrowserHeight(-1); options.setFormat(ImageFormat.JPG); options.setTargetElement("#features"); grabzIt.URLToImage("http://www.bbc.co.uk/news", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.jpg");