Vectorizer.AI มี API การแปลงบิตแมปเต็มรูปแบบ API จะแปลงพิกเซลเป็นเวกเตอร์อย่างครบถ้วนโดยอัตโนมัติ และมีความเที่ยงตรงเหนือชั้นกว่าเครื่องมืออื่นในระดับเดียวกัน
โพสต์ภาพบิตแมปและรอรับผลลัพธ์ที่เป็นภาพเวกเตอร์กลับมา
$ curl https://th.vectorizer.ai/api/v1/vectorize \ -u xyz123:[secret] \ -F image=@example.jpeg \ -o result.svg
// Requires: org.apache.httpcomponents.client5:httpclient5-fluent Request request = Request.post("https://th.vectorizer.ai/api/v1/vectorize") .addHeader("Authorization", "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd") .body( MultipartEntityBuilder.create() .addBinaryBody("image", new File("example.jpeg")) // TODO: Replace with your image // TODO: Add more upload parameters here .build() ); ClassicHttpResponse response = (ClassicHttpResponse) request.execute().returnResponse(); if (response.getCode() == 200) { // Write result to disk, TODO: or wherever you'd like try (FileOutputStream out = new FileOutputStream("result.svg")) { response.getEntity().writeTo(out); } } else { System.out.println("Request Failed: Status: " + response.getCode() + ", Reason: " + response.getReasonPhrase()); }
using (var client = new HttpClient()) using (var form = new MultipartFormDataContent()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "INSERT_API_KEY_HERE"); form.Add(new ByteArrayContent(File.ReadAllBytes("example.jpeg")), "image", "example.jpeg"); // TODO: Replace with your image // TODO: Add more upload parameters here var response = client.PostAsync("https://th.vectorizer.ai/api/v1/vectorize", form).Result; if (response.IsSuccessStatusCode) { // Write result to disk, TODO: or wherever you'd like FileStream outStream = new FileStream("result.svg", FileMode.Create, FileAccess.Write, FileShare.None); response.Content.CopyToAsync(outStream).ContinueWith((copyTask) => { outStream.Close(); }); } else { Console.WriteLine("Request Failed: Status: " + response.StatusCode + ", Reason: " + response.ReasonPhrase); } }
// Requires "request" to be installed (see https://www.npmjs.com/package/request) var request = require('request'); var fs = require('fs'); request.post({ url: 'https://th.vectorizer.ai/api/v1/vectorize', formData: { image: fs.createReadStream('example.jpeg'), // TODO: Replace with your image // TODO: Add more upload options here }, auth: {user: 'xyz123', pass: '[secret]'}, followAllRedirects: true, encoding: null }, function(error, response, body) { if (error) { console.error('Request failed:', error); } else if (!response || response.statusCode != 200) { console.error('Error:', response && response.statusCode, body.toString('utf8')); } else { // Save result fs.writeFileSync("result.svg", body); } });
$ch = curl_init('https://th.vectorizer.ai/api/v1/vectorize'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd')); curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => curl_file_create('example.jpeg'), // TODO: Add more upload options here )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200) { // Save result file_put_contents("result.svg", $data); } else { echo "Error: " . $data; } curl_close($ch);
# Requires "requests" to be installed (see python-requests.org) import requests response = requests.post( 'https://th.vectorizer.ai/api/v1/vectorize', files={'image': open('example.jpeg', 'rb')}, data={ # TODO: Add more upload options here }, headers={ 'Authorization': 'Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd' }, ) if response.status_code == requests.codes.ok: # Save result with open('result.svg', 'wb') as out: out.write(response.content) else: print("Error:", response.status_code, response.text)
# Requires: gem install httpclient require 'httpclient' client = HTTPClient.new default_header: { "Authorization" => "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd" } response = client.post("https://th.vectorizer.ai/api/v1/vectorize", { "image" => File.open("example.jpeg", "rb"), # TODO: Replace with your image # TODO: Add more upload parameters here }) if response.status == 200 then # Write result to disk, TODO: or wherever you'd like File.open("result.svg", 'w') { |file| file.write(response.body) } else puts "Error: Code: " + response.status.to_s + ", Reason: " + response.reason end
$ curl https://th.vectorizer.ai/api/v1/vectorize \ -u xyz123:[secret] \ -F 'image.url=https://example.com/example.jpeg' \ -o result.svg
// Requires: org.apache.httpcomponents.client5:httpclient5-fluent Request request = Request.post("https://th.vectorizer.ai/api/v1/vectorize") .addHeader("Authorization", "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd") .body( MultipartEntityBuilder.create() .addTextBody("image.url", "https://example.com/example.jpeg") // TODO: Replace with your image URL // TODO: Add more upload parameters here .build() ); ClassicHttpResponse response = (ClassicHttpResponse) request.execute().returnResponse(); if (response.getCode() == 200) { // Write result to disk, TODO: or wherever you'd like try (FileOutputStream out = new FileOutputStream("result.svg")) { response.getEntity().writeTo(out); } } else { System.out.println("Request Failed: Status: " + response.getCode() + ", Reason: " + response.getReasonPhrase()); }
using (var client = new HttpClient()) using (var form = new MultipartFormDataContent()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "INSERT_API_KEY_HERE"); form.Add(new StringContent("https://example.com/example.jpeg"), "image.url"); // TODO: Replace with your image URL // TODO: Add more upload parameters here var response = client.PostAsync("https://th.vectorizer.ai/api/v1/vectorize", form).Result; if (response.IsSuccessStatusCode) { // Write result to disk, TODO: or wherever you'd like FileStream outStream = new FileStream("result.svg", FileMode.Create, FileAccess.Write, FileShare.None); response.Content.CopyToAsync(outStream).ContinueWith((copyTask) => { outStream.Close(); }); } else { Console.WriteLine("Request Failed: Status: " + response.StatusCode + ", Reason: " + response.ReasonPhrase); } }
// Requires "request" to be installed (see https://www.npmjs.com/package/request) var request = require('request'); var fs = require('fs'); request.post({ url: 'https://th.vectorizer.ai/api/v1/vectorize', formData: { 'image.url': 'https://example.com/example.jpeg', // TODO: Replace with your image // TODO: Add more upload options here }, auth: {user: 'xyz123', pass: '[secret]'}, followAllRedirects: true, encoding: null }, function(error, response, body) { if (error) { console.error('Request failed:', error); } else if (!response || response.statusCode != 200) { console.error('Error:', response && response.statusCode, body.toString('utf8')); } else { // Save result fs.writeFileSync("result.svg", body); } });
$ch = curl_init('https://th.vectorizer.ai/api/v1/vectorize'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd')); curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image.url' => 'https://example.com/example.jpeg', // TODO: Add more upload options here )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200) { // Save result file_put_contents("result.svg", $data); } else { echo "Error: " . $data; } curl_close($ch);
# Requires "requests" to be installed (see python-requests.org) import requests response = requests.post( 'https://th.vectorizer.ai/api/v1/vectorize', data={ 'image.url': 'https://example.com/example.jpeg', # TODO: Add more upload options here }, headers={ 'Authorization': 'Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd' }, ) if response.status_code == requests.codes.ok: # Save result with open('result.svg', 'wb') as out: out.write(response.content) else: print("Error:", response.status_code, response.text)
# Requires: gem install httpclient require 'httpclient' client = HTTPClient.new default_header: { "Authorization" => "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd" } response = client.post("https://th.vectorizer.ai/api/v1/vectorize", { "image.url" => "https://example.com/example.jpeg", # TODO: Replace with your image URL # TODO: Add more upload parameters here }) if response.status == 200 then # Write result to disk, TODO: or wherever you'd like File.open("result.svg", 'w') { |file| file.write(response.body) } else puts "Error: Code: " + response.status.to_s + ", Reason: " + response.reason end
มันเป็นอิสระที่จะบูรณาการกับและทดสอบ API, ไม่จำเป็นต้องสมัครสมาชิก.
Production results require a subscription and are 1.00 credits each.
นอกจากนี้เรายังเสนอผลการแสดงตัวอย่างที่คุณสามารถแสดงผู้ใช้ของคุณก่อนที่จะทำการซื้อ ภาพตัวอย่างเป็นภาพ PNG ใหญ่กว่าภาพที่คุณป้อนถึงสี่เท่า และมาพร้อมกับลายน้ำที่ละเอียดรอบคอบ Previews are 0.20 credits each.
โปรดดู หน้าราคา สำหรับแผนการสมัครสมาชิก
API ใช้ การรับรองความถูกต้องเบื้องต้นของการเข้าถึง HTTP แบบมาตรฐาน คำร้องขอทั้งหมดถึง API ต้องดำเนินการผ่าน HTTPS และมีข้อมูลประจำตัว API ของคุณ โดยมี API Id เป็นผู้ใช้ และรหัสลับ API เป็นรหัสผ่าน
ไลบรารีไคลเอ็นต์ http ของคุณต้องรองรับ การบ่งชี้ชื่อเซิร์ฟเวอร์ (SNI) จึงจะส่งคำขอได้สำเร็จ หากคุณได้รับข้อผิดพลาดการสื่อสารที่ผิดปกติ ก็น่าจะเป็นเพราะเหตุนี้มากที่สุด
การใช้งาน API มีอัตราที่จำกัด โดยเผื่อค่าไว้กว้างและไม่มีขอบเขตบนที่เคร่งครัด
ในระหว่างการดำเนินการที่ผู้ใช้ปลายทางกระทำตามปกตินั้น มีโอกาสน้อยที่คุณจะประสบกับอัตราที่จำกัด เพราะการใช้งานมีแนวโน้มที่จะขึ้น ๆ ลง ๆ ในลักษณะที่บริการจัดการได้อย่างเรียบร้อย
อย่างไรก็ตาม ในกรณีของชุดงาน เราขอแนะนำให้เริ่มต้นด้วยชุดกิจกรรมสูงสุด 5 ชุด โดยเพิ่มใหม่ 1 ชุดทุก ๆ 5 นาที จนกว่าคุณจะไปถึงระดับการทำงานแบบขนานตามที่ต้องการ กรุณาแจ้งให้เราทราบก่อนที่คุณจะเริ่มงาน หากต้องการชุดกิจกรรมมากกว่า 100 ชุดพร้อมกัน
หากคุณส่งคำขอมากเกินไป คุณจะเริ่มได้รับผลตอบกลับ 429 Too Many Requests
เมื่อเกิดกรณีเช่นนี้ขึ้น คุณควรปรับใช้กลยุทธ์สุ่มรอเวลาแบบเส้นตรง : ในผลตอบกลับดังกล่าวครั้งแรก รอ 5 วินาที ก่อนส่งคำขอถัดไป ในผลตอบกลับ 429 ที่ต่อเนื่องกันครั้งที่สอง รอ 2*5=10 วินาที ก่อนส่งคำขอถัดไป ส่วนครั้งที่สาม จะรอ 3*5=15 วินาที ฯลฯ
คุณสามารถรีเซ็ตตัวนับการสุ่มรอเวลาหลังจากคำขอประสบผลสำเร็จ และคุณควรนำการสุ่มรอเวลาไปใช้กับแต่ละชุดกิจกรรม (กล่าวคือ ชุดกิจกรรมควรทำหน้าที่โดยอิสระไม่ขึ้นต่อกันและกัน)
POST
https://api.vectorizer.ai/api/v1/vectorize
ในการปรับภาพให้เป็นเวกเตอร์ คุณจะทำการอัปโหลดไฟล์ HTTP POST แบบมาตรฐาน อย่าลืมว่า ประเภท-เนื้อหา ต้องเป็น multipart/form-data
เมื่ออัปโหลดไฟล์ไบนารี
ตารางด้านล่างแสดงพารามิเตอร์ทั้งหมดของ API ในแบบฟอร์ม "ลองใช้ตอนนี้" ที่ใช้งานได้ พารามิเตอร์แต่ละตัวมีคำอธิบายสั้น ๆ แต่อย่าลืมอ่านเอกสารที่มีรายละเอียดเกี่ยวกับตัวเลือกเอาต์พุต
วันที่ | เปลี่ยน |
---|---|
20 ก.ย. 2023 |
ได้เพิ่ม mode
|
1 ส.ค. 2023 |
เพิ่มกลุ่มตัวเลือกขนาดเอาต์พุตที่มีคุณสมบัติครบถ้วนด้วยตัวเลือกต่อไปนี้: output.size.scale , output.size.width , output.size.height , output.size.unit , output.size.aspect_ratio , output.size.align_x , output.size.align_y , output.size.input_dpi และ output.size.output_dpi เพิ่มกลุ่มตัวเลือกเอาต์พุตบิตแมปด้วยตัวเลือกเดียว: output.bitmap.anti_aliasing_mode
|
7 มิ.ย. 2023 |
ได้เพิ่ม processing.max_colors
|
31 พ.ค. 2023 | เพิ่มพารามิเตอร์ API ให้มากขึ้นอีกมาก อัปเดตให้ URL ที่เป็นจุดหมายของ API |
10 มี.ค. 2023 | ออกเผยแพร่ครั้งแรก |