Skip to content

Commit a99450c

Browse files
committed
Merge pull request #18 from jabooth/v040
bump to menpo v0.6.x series
2 parents a57c394 + f0379ca commit a99450c

File tree

6 files changed

+17
-33
lines changed

6 files changed

+17
-33
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ docs/_build/
5454

5555
# IntelliJ
5656
*.iml
57+
58+
.idea

conda/meta.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ requirements:
1010
run:
1111
- python
1212
- pathlib 1.0 # [py2k]
13-
- enum 0.4.4 # [py2k]
14-
- menpo 0.4.0|>=0.4.1,<0.5.0 # Make sure we ignore the alpha
15-
- menpo3d 0.1.0|>=0.1.1,<0.2.0 # Make sure we ignore the alpha
13+
- enum 0.4.4 # [py2k]
14+
- menpo 0.6.*
15+
- menpo3d 0.3.*
1616
- flask 0.10.1
1717
- flask-restful 0.2.12
18-
- cherrypy 3.6.0
18+
- cherrypy 3.8.0
1919
- joblib 0.8.4
2020
- pyyaml 3.11
2121

landmarkerio/asset.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ class ImageAdapter(object):
1212
"""
1313
__metaclass__ = abc.ABCMeta
1414

15-
@abc.abstractmethod
16-
def image_info(self, asset_id):
17-
pass
18-
1915
@abc.abstractmethod
2016
def texture_file(self, asset_id):
2117
pass
@@ -55,10 +51,6 @@ def __init__(self, cache_dir):
5551
CacheFile.image))
5652
if a.parent.parent == self.cache_dir]
5753

58-
def image_info(self, asset_id):
59-
return reduce(safe_join,
60-
(str(self.cache_dir), asset_id, CacheFile.image))
61-
6254
def texture_file(self, asset_id):
6355
return reduce(safe_join, (str(self.cache_dir),
6456
asset_id, CacheFile.texture))

landmarkerio/cache.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import os
32
import os.path as p
43
from os.path import expanduser, abspath
@@ -17,6 +16,8 @@
1716
from landmarkerio import CacheFile
1817

1918

19+
# identifier functions
20+
2021
def filename_as_asset_id(fp):
2122
# simply return the filename as the asset_id
2223
return Path(fp).stem
@@ -106,19 +107,14 @@ def _cache_image_for_id(cache_dir, asset_id, img):
106107
# WebGL only allows textures of maximum dimension 4096
107108
ratio = 4096.0 / np.array(img.shape)
108109
if np.any(ratio < 1):
109-
# the largest axis of img will now be 4096
110-
img = img.rescale(ratio.min(), round='round')
111-
had_to_shrink = True
112-
else:
113-
had_to_shrink = False
114-
# 1. Save out the image metadata json
115-
image_info = {'width': img.width,
116-
'height': img.height}
117-
with open(image_info_path, 'wb') as f:
118-
json.dump(image_info, f)
110+
# the largest axis of the img could be too big for older browsers.
111+
# Give a warning.
112+
print('Warning: {} has shape {}. Dims larger than 4096 may have '
113+
'issues rendering in older browsers.'.format(asset_id,
114+
img.shape))
119115

120116
# 2. Save out the image
121-
if img_path.suffix == '.jpg' and not had_to_shrink:
117+
if img_path.suffix == '.jpg':
122118
# Original was a jpg that was suitable, save it
123119
shutil.copyfile(str(img_path), texture_path)
124120
else:

landmarkerio/server.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,6 @@ def add_image_endpoints(api, adapter):
241241
all data to pass to landmarker.io.
242242
243243
"""
244-
class Image(Resource):
245-
246-
def get(self, asset_id):
247-
err = "{} does not have an image".format(asset_id)
248-
return json_file(adapter.image_info(asset_id), err)
249244

250245
class ImageList(Resource):
251246

@@ -269,7 +264,6 @@ def get(self, asset_id):
269264
thumbnail_url = partial(url, Endpoints.thumbnail)
270265

271266
api.add_resource(ImageList, image_url())
272-
api.add_resource(Image, asset(image_url)())
273267

274268
api.add_resource(Texture, asset(texture_url)())
275269
api.add_resource(Thumbnail, asset(thumbnail_url)())

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import sys
44
import versioneer
55

6-
install_requires = ['menpo>=0.4.0,<0.5',
7-
'menpo3d>=0.1.0,<0.2',
6+
install_requires = ['menpo>=0.6,<0.7',
7+
'menpo3d>=0.3,<0.4',
88
'Flask>=0.10.1',
99
'Flask-RESTful>=0.2.12',
10-
'CherryPy>=3.6.0',
10+
'CherryPy>=3.8.0',
1111
'joblib>=0.8.4',
1212
'PyYaml>=3.11']
1313

0 commit comments

Comments
 (0)