Skip to content

Commit a53b961

Browse files
author
Liam Cain
committed
works on windows now. Fixed issue with width and height
1 parent d6275e1 commit a53b961

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

autofilename.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def insert_dimension(self,edit,dim,name,tag_scope):
1111
view = self.view
1212
sel = view.sel()[0].a
1313
if name in view.substr(tag_scope):
14-
reg = view.find('(?<=name\=)\s*\"\d{1,5}', tag_scope.a)
14+
reg = view.find('(?<='+name+'\=)\s*\"\d{1,5}', tag_scope.a)
1515
view.replace(edit, reg, '"'+str(dim.get(name)))
1616
else:
1717
dimension = str(dim.get(name))
@@ -33,7 +33,7 @@ def run(self, edit):
3333
path = path[path.rfind('/'):]
3434
full_path = self.this_dir + path
3535
if '<img' in view.substr(tag_scope) and path.endswith(('.png','.jpg','.jpeg','.gif')):
36-
with open(full_path,'r') as r:
36+
with open(full_path,'rb') as r:
3737
read_data = r.read()
3838
dim = get_image_size(read_data)
3939
self.insert_dimension(edit,dim,'width',tag_scope)
@@ -70,7 +70,7 @@ def will_commit(self, view):
7070
def fix_dir(self,sdir,fn):
7171
if fn.endswith(('.png','.jpg','.jpeg','.gif')):
7272
path = os.path.join(sdir + '/', fn)
73-
with open(path,'r') as r:
73+
with open(path,'rb') as r:
7474
read_data = r.read()
7575
dim = get_image_size(read_data)
7676
return fn + '\t' + 'w:'+str(dim.get('width'))+" h:"+str(dim.get('height'))

0 commit comments

Comments
 (0)