Repository navigation
Expand file tree
/
Copy pathexample.php
More file actions
57 lines (40 loc) · 1.4 KB
/
Copy pathexample.php
File metadata and controls
57 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/*
www.WhatFontIs.com
Find any font from any image (commercial or free)
Using a catalogue of 1.2M+ fonts (commercial or free) and font finder AI, for every image uploaded we show over 60 similar fonts ( free or commercial).
More info here:
https://www.whatfontis.com/API-identify-fonts-from-image.html
Please modify XXXXXXXX from API_KEY with your API key, then run: php example.php
*/
$file=file_get_contents('A.png');
$encdeod= base64_encode($file);
$curl = curl_init();
$data = array(
'API_KEY' => 'XXXXXXXX',
'IMAGEBASE64' => '1',
// 0 = find the text in the image first (photos, screenshots).
// 1 = the image is already a tight crop of the letters.
'NOTTEXTBOXSDETECTION' => '0',
'urlimage' => '',
'urlimagebase64' => $encdeod,
// how many matches to return, best first
'limit' => '20'
);
curl_setopt($curl, CURLOPT_URL, 'https://www.whatfontis.com/api2/');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$read_fonts_json = curl_exec($curl);
if(curl_errno($curl)){
echo 'Curl error: ' . curl_error($curl) . "\n";
curl_close($curl);
exit(1);
}
curl_close($curl);
$read_fonts=json_decode($read_fonts_json);
if ($read_fonts === null) {
echo "Could not decode the API response:\n" . $read_fonts_json . "\n";
exit(1);
}
print_r($read_fonts);