ویب پر گرفت اور تبدیل کرنے کے اوزار

ویب سائٹ اسکرین شاٹس پر قبضہ کریں یا HTML کو امیجز میں تبدیل کریں

روبی API

ویب صفحات کے بہتر امیج اسکرین شاٹس تیار کریں یا مندرجہ ذیل خصوصیات کی مدد سے HTML کو براہ راست تصاویر میں تبدیل کریں GrabzIt کا روبی API. تاہم ، اس سے پہلے کہ آپ فون کریں ، یاد رکھیں url_to_image, html_to_image or file_to_image طریقوں save or save_to شبیہہ بنانے کے ل method طریقہ کو بلایا جانا چاہئے۔

بنیادی اختیارات

ویب پیج یا اسکرین شاٹ لینے کیلئے صرف ایک پیرامیٹر کی ضرورت ہے HTML کو تبدیل کریں intOA تصویر جیسا کہ مندرجہ ذیل مثال میں دکھایا گیا ہے۔

grabzItClient.url_to_image("https://www.tesla.com")
# Then call the save or save_to method
grabzItClient.html_to_image("<html><body><h1>Hello World!</h1></body></html>")
# Then call the save or save_to method
grabzItClient.file_to_image("example.html")
# Then call the save or save_to method

تصویری شکلیں

GrabzIt کا روبی API متعدد فارمیٹس میں تصویری اسکرین شاٹس لے سکتا ہے ، جس میں جے پی جی ، PNG ، WEBP ، BMP (8 بٹ ، 16 بٹ ، 24 بٹ یا 32 بٹ) اور TIFF شامل ہیں۔ تصویری اسکرین شاٹس کے لئے پہلے سے طے شدہ شکل JPG ہے۔ تاہم ، ان حالات میں جے پی جی امیج کا معیار اتنا اچھا نہیں ہوسکتا ہے کہ PNG فارمیٹ کو امیج اسکرین شاٹس کے ل for تجویز کیا جاتا ہے کیونکہ یہ معیار اور فائل کے سائز کے درمیان اچھا توازن فراہم کرتا ہے۔ ذیل کی مثال PNG فارمیٹ کا استعمال کرتے ہوئے لی گئی ایک امیج اسکرین شاٹ کو دکھاتی ہے۔

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.format = "png"

grabzItClient.url_to_image("https://www.tesla.com", options)
# Then call the save or save_to method
grabzItClient.save_to("result.png")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.format = "png"

grabzItClient.html_to_image("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the save or save_to method
grabzItClient.save_to("result.png")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.format = "png"

grabzItClient.file_to_image("example.html", options)
# Then call the save or save_to method
grabzItClient.save_to("result.png")

براؤزر کا سائز

براؤزر کا سائز براؤزر ونڈو کے سائز سے مراد ہے جو زیادہ تر معاملات میں اسکرین شاٹ کی گرفتاری کے وقت استعمال ہوگا جب کہ یہ طے کرنے کی ضرورت نہیں ہے کیونکہ تمام تر کاموں کے لئے پہلے سے طے شدہ براؤزر کا سائز کافی ہوگا۔ براؤزر کے سائز کو سیٹ کرنے کے لئے صرف ایک ویلیو کو پاس کریں browserWidth اور browserHeight کے طریقوں ImageOptions کلاس.

تصویری سائز تبدیل کریں

کسی شبیہہ کے سائز کو تبدیل کرنا آسان ہے ، تصویر کو مسخ کیے بغیر کرنا کچھ مشکل ہے۔ پورے عمل کو آسان بنانے کے ل we ہم آپ کو مشورہ دیتے ہیں کہ آپ اسے استعمال کریں سادہ تصویری جہت کیلکولیٹر.

اگر آپ تصویری چوڑائی اور اونچائی کو براؤزر کی چوڑائی اور اونچائی سے بڑے سائز میں بڑھانا چاہتے ہیں ، جو 1366 بذریعہ 728 پکسلز ہے ، تو براؤزر کی چوڑائی اور اونچائی کو بھی میچ کرنے کیلئے بڑھانا ہوگا۔

کسٹم شناختی

آپ کو ایک کسٹم شناخت کنندہ پاس کرسکتے ہیں تصویر جیسا کہ ذیل میں دکھایا گیا ہے ، اس کی قیمت آپ کے GrabzIt روبی ہینڈلر کو واپس کردی جاتی ہے۔ مثال کے طور پر یہ کسٹم شناخت کنندہ ایک ڈیٹا بیس شناخت کنندہ ہوسکتا ہے ، جس سے اسکرین شاٹ کو کسی خاص ڈیٹا بیس ریکارڈ کے ساتھ وابستہ کیا جاسکتا ہے۔

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.customId = "123456"

grabzItClient.url_to_image("https://www.tesla.com", options)
# Then call the save method
grabzItClient.save("http://www.example.com/handler/index")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.customId = "123456"

grabzItClient.html_to_image("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the save method
grabzItClient.save("http://www.example.com/handler/index")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.customId = "123456"

grabzItClient.file_to_image("example.html", options)
# Then call the save method
grabzItClient.save("http://www.example.com/handler/index")

مکمل لمبائی اسکرین شاٹ

GrabzIt آپ کو ایک پورے ویب پیج کی مکمل لمبائی کا اسکرین شاٹ لینے کی اجازت دیتا ہے اس کے ل you آپ کو ایک ایکس ایکس ایکس ایکس پاس کرنے کی ضرورت ہے browserHeight طریقہ اس بات کا یقین کرنے کے لئے کہ براؤزر کے سائز سے مماثلت مماثلت رکھتی ہو ، اس کو ایک -1 پاس سے گزریں height اور width اوصاف.

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.browserHeight = -1
options.width = -1
options.height = -1

grabzItClient.url_to_image("https://www.tesla.com", options)
# Then call the save or save_to method
grabzItClient.save_to("result.jpg")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.browserHeight = -1
options.width = -1
options.height = -1

grabzItClient.html_to_image("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the save or save_to method
grabzItClient.save_to("result.jpg")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.browserHeight = -1
options.width = -1
options.height = -1

grabzItClient.file_to_image("example.html", options)
# Then call the save or save_to method
grabzItClient.save_to("result.jpg")

آپ تھمب نیل بھی واپس کرسکتے ہیں جو فصل نہیں لگے ہیں ، لیکن ہوشیار رہیں کہ اس سے بڑی تصاویر تشکیل دے سکتی ہیں۔ ایسا کرنے کے ل a ایک -1 پاس کریں height اور / یا width طریقوں. جس طول و عرض کو -1 منظور کیا گیا ہے وہ فصل نہیں کی جائے گی۔

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.width = -1
options.height = -1

grabzItClient.url_to_image("https://www.tesla.com", options)
# Then call the save or save_to method
grabzItClient.save_to("result.jpg")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.width = -1
options.height = -1

grabzItClient.html_to_image("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the save or save_to method
grabzItClient.save_to("result.jpg")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::ImageOptions.new()
options.width = -1
options.height = -1

grabzItClient.file_to_image("example.html", options)
# Then call the save or save_to method
grabzItClient.save_to("result.jpg")
نوٹ کریں براؤزر کی پوری چوڑائی نہیں ہے!

ان خصوصی قدروں کو استعمال کرنے کا مطلب یہ ہے کہ آپ ایک اسکرین شاٹ تشکیل دے سکتے ہیں جو اگر آپ چاہیں تو پورے ویب پیج کا مکمل پیمانہ ورژن ہے۔

کسی صفحہ عنصر کا اسکرین شاٹ لیں

GrabzIt آپ کو HTML عنصر کا اسکرین شاٹ لینے کی اجازت دیتا ہے ، جیسے کہ div or span ٹیگ ، اور اس کے تمام مواد پر قبضہ. اس کے ل To ، HTML عنصر جس کی آپ اسکرین شاٹ لینا چاہتے ہیں اسے بطور درج ہونا ضروری ہے سی ایس ایس سلیکٹر.

...
<div id="features">
	<img src="http://www.example.com/rocket.jpg"/><h3>Rocket Launch Next Week</h3>
</div>
...

ذیل کی مثال کے طور پر ہم id کو "خصوصیات" کے ساتھ منتخب کریں گے اور اسے 250 x 250px JPEG تصویر کے بطور برآمد کریں گے۔

grabzItClient = GrabzIt::Client.new("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
options = GrabzIt::ImageOptions.new()
options.width = 250
options.height = 250
options.format = "jpg"
options.targetElement = "#features"

grabzItClient.url_to_image("http://www.bbc.co.uk/news", options)
# Then call the save or save_to method
grabzItClient.save_to("result.jpg")

اگلی مثال "خصوصیات" ڈیو کا دوسرا اسکرین شاٹ لیتا ہے لیکن اس بار جے پی ای جی کی ایک تصویر سامنے آتی ہے جو Div کا عین مطابق سائز ہے۔

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

# The -1 indicates that image should not be cropped
options = GrabzIt::ImageOptions.new()
options.width = 250
options.height = 250
options.format = "jpg"
options.targetElement = "#features"
options.browserHeight = -1

grabzItClient.url_to_image("http://www.bbc.co.uk/news", options)
# Then call the save or save_to method
grabzItClient.save_to("result.jpg")