File tree Expand file tree Collapse file tree 1 file changed +5
-15
lines changed
src/jupyter_contrib_nbextensions/nbconvert_support Expand file tree Collapse file tree 1 file changed +5
-15
lines changed Original file line number Diff line number Diff line change 5
5
import re
6
6
import os
7
7
import base64
8
- from urllib .request import urlopen
9
- from io import StringIO
10
8
from ipython_genutils .ipstruct import Struct
11
9
10
+ try :
11
+ from urllib .request import urlopen # py3
12
+ except ImportError :
13
+ from urllib2 import urlopen
14
+
12
15
13
16
class EmbedImagesPreprocessor (Preprocessor ):
14
17
"""
@@ -69,19 +72,6 @@ def replfunc_md(self, match):
69
72
with open (filename , 'rb' ) as f :
70
73
data = f .read ()
71
74
72
- # TODO: scale image...
73
- if self .dpi_scaling > 0 and imgformat in ['png' , 'jpg' ]:
74
- try :
75
- import pillow as PIL
76
- except ImportError :
77
- self .log .info ("pillow library not available to scale images" )
78
- if PIL :
79
- #im = PIL.Image.open(StringIO(data))
80
- #size = 128, 128
81
- #im.thumbnail(size, PIL.Image.ANTIALIAS)
82
- #data = im.save()
83
- self .log .info ("Rescaled image %s to size %d x %d pixels" % (imgname , size ) )
84
-
85
75
self .log .debug ("embedding url: %s, format: %s" % (url , imgformat ))
86
76
b64_data = base64 .b64encode (data ).decode ("utf-8" )
87
77
self .attachments [url ] = { 'image/' + imgformat : b64_data }
You can’t perform that action at this time.
0 commit comments