ih moule
This commit is contained in:
parent
1a0150e93f
commit
e3aaa365b4
0
ih/__init__.py
Normal file
0
ih/__init__.py
Normal file
33
ih/files.py
Normal file
33
ih/files.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import os
|
||||
|
||||
|
||||
# Return file string and filename
|
||||
def get_file_from_request(request, fieldname):
|
||||
file_l = ''
|
||||
for i in request.FILES[fieldname]:
|
||||
file_l = file_l + i
|
||||
|
||||
return file_l, str(request.FILES[fieldname])
|
||||
|
||||
|
||||
# Write file to /dev/shm and return ar handler
|
||||
def write_to_shm(file, name):
|
||||
f = open('/dev/shm/' + name, 'w')
|
||||
f.write(file)
|
||||
f.close()
|
||||
|
||||
return '/dev/shm/' + name
|
||||
|
||||
|
||||
# Remove file from /dev/shm
|
||||
def rm_from_shm(name):
|
||||
try:
|
||||
os.remove('/dev/shm/' + name)
|
||||
return True
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
|
||||
# Split filename
|
||||
def split_file(filename):
|
||||
pass
|
12
ih/images.py
Normal file
12
ih/images.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from PIL import Image
|
||||
|
||||
def resize_image(fh, img_prop):
|
||||
im = Image.open(fh)
|
||||
# size = 100, 100
|
||||
im.thumbnail(img_prop['size'])
|
||||
print img_prop['size']
|
||||
# im.thumbnail(size)
|
||||
thumb_name = img_prop['dest'] + '/thumb_' + img_prop['name']
|
||||
im.save(thumb_name)
|
||||
|
||||
return thumb_name
|
Loading…
Reference in New Issue
Block a user