jgomezdans / geog_docker

Docker image for Geospatial Python teaching
GNU General Public License v3.0
4 stars 1 forks source link

Logo #9

Open profLewis opened 4 years ago

profLewis commented 4 years ago

A notebook logo might be cool. I've some code to generate the 32x32 and 64x64 logo files you need, but I'm not sure where to insert them, other than in the kernel directory.

profLewis commented 4 years ago

def make_icons(self,spec): ''' Use UCL icon file to make 64 x 64 and 32 x 32 logo images and store in resource dir

spec: directory to place icons

'''

sort directory for op

allow use of ~

resource_dir = Path(spec).expanduser()

mkdir

resource_dir.mkdir(parents=True, exist_ok=True) #

put logo file in resource dir

# ucllogo = Path(resource_dir).joinpath('ucl_logo.png') logo3232 = Path(resource_dir).joinpath('logo-32x32.png') logo6464 = Path(resource_dir).joinpath('logo-64x64.png') url = 'https://raw.githubusercontent.com/UCL-EO/uclgeog/master/images/ucl_logo.png' try: r = requests.get(url, allow_redirects=True) open(ucllogo, 'wb').write(r.content)

now make logo

image = Image.open(ucllogo)
aspect_ratio = image.size[0]/image.size[1]
big = int(aspect_ratio * 64)
image = image.resize((big,64),Image.ANTIALIAS)
new_im = Image.new('RGB',(big,big),(255, 255, 255)) # White
new_im.paste(image, image.getbbox())  # Not cent
new_im.resize((64,64),\
  Image.ANTIALIAS).save(logo6464)
new_im.resize((32,32),\
  Image.ANTIALIAS).save(logo3232)
return new_im

except: return None

jgomezdans commented 4 years ago

There's a file in the home folder that allows you to use these things, need to check where this is.

jgomezdans commented 4 years ago

Says here you need to

  1. Add a little js file to $NB_HOME/.jupyter/custom/
  2. Copy the favicon.ico file to that folder

Hassle is notebook/lab interface have different ways to set this.

profLewis commented 4 years ago

perfect!