Skip to content

Commit 9d9216d

Browse files
author
bkwi
authored
Added image OCR (#52)
* Added method for OCR * Updated requirements
1 parent 0066cf9 commit 9d9216d

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ python:
55
- "3.5"
66
- "3.6"
77
- "3.7"
8-
- "3.8-dev"
8+
- "3.8"
99

1010
install:
1111
- pip install -r requirements.txt

filestack/mixins/common.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def get_content(self, security=None):
9898

9999
def tags(self, security=None):
100100
"""
101-
Performs image tagging operation on current object
101+
Performs image tagging operation on current object (image)
102102
103103
Args:
104104
security (:class:`filestack.Security`): Security object that will be used
@@ -125,3 +125,18 @@ def sfw(self, security=None):
125125
obj = self._add_transform_task('sfw', params={'self': None})
126126
response = requests.get(obj.signed_url(security=security))
127127
return response.json()
128+
129+
def ocr(self, security=None):
130+
"""
131+
Performs OCR on current object (image)
132+
133+
Args:
134+
security (:class:`filestack.Security`): Security object that will be used
135+
to run OCR
136+
137+
Returns:
138+
`dict`: dictionary containing OCR data
139+
"""
140+
obj = self._add_transform_task('ocr', params={'self': None})
141+
response = requests.get(obj.signed_url(security=security))
142+
return response.json()

filestack/models/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Client:
1919
and provide a Security object to sign all your API calls.
2020
2121
>>> from filestack import Client, Security
22-
>>> security = Security(policy={'expiry': 1594200833, '<YOUR APP SECRET>'})
22+
>>> security = Security(policy={'expiry': 1594200833}, secret='YOUR APP SECRET')
2323
>>> cli = Client('<FILESTACK_APIKEY>', storage='gcs', security=security)
2424
"""
2525
def __init__(self, apikey, storage='S3', security=None):

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ coveralls==1.1
22
httmock==1.2.6
33
pytest==4.6.3
44
pytest-cov==2.5.0
5-
requests==2.22.0
5+
requests==2.24.0
66
responses==0.10.6
7-
trafaret==1.2.0
7+
trafaret==2.0.2

0 commit comments

Comments
 (0)