copied thumbnailer functions to main generator
This commit is contained in:
43
Qalbum.py
43
Qalbum.py
@@ -194,26 +194,37 @@ def createthumbs(path,list):
|
||||
os.mkdir(os.path.join(path,'_med'))
|
||||
n=1
|
||||
nsum=len(list)
|
||||
r='1000'
|
||||
for i in list:
|
||||
if (vectorsearch.match(i)):
|
||||
if not os.path.exists(os.path.join(path,'_med','med_'+i+'.jpg')):
|
||||
print('.. '+i+' '+str(n)+'/'+str(nsum))
|
||||
convargs=['convert','-density','300x300',os.path.join(path,i)+'[0]','-background','white','-flatten','-resize','1000x1000>','-quality','97',os.path.join(path,'_med','med_'+i+'.jpg')]
|
||||
convp=subprocess.call(convargs)
|
||||
if not os.path.exists(os.path.join(path,'_tn','tn_'+i+'.jpg')):
|
||||
convargs=['convert','-density','300x300',os.path.join(path,'_med','med_'+i+'.jpg'),'-background','white','-flatten','-thumbnail','90x90^','-gravity','Center','-crop','90x90+0+0','+repage','-quality','75',os.path.join(path,'_tn','tn_'+i+'.jpg')]
|
||||
convp=subprocess.call(convargs)
|
||||
else:
|
||||
if not os.path.exists(os.path.join(path,'_med','med_'+i+'.jpg')):
|
||||
print('.. '+i+' '+str(n)+'/'+str(nsum))
|
||||
convargs=['convert','-define','jpeg:size=1200x1200',os.path.join(path,i)+'[0]','-background','white','-flatten','-resize','1000x1000>','-quality','85',os.path.join(path,'_med','med_'+i+'.jpg')]
|
||||
convp=subprocess.call(convargs)
|
||||
if not os.path.exists(os.path.join(path,'_tn','tn_'+i+'.jpg')):
|
||||
convargs=['convert','-define','jpeg:size=300x300',os.path.join(path,'_med','med_'+i+'.jpg'),'-background','white','-flatten','-thumbnail','90x90^','-gravity','Center','-crop','90x90+0+0','+repage','-quality','75',os.path.join(path,'_tn','tn_'+i+'.jpg')]
|
||||
convp=subprocess.call(convargs)
|
||||
outmedium=os.path.join(path,'_med','med_'+i+'.jpg')
|
||||
outthumb=os.path.join(path,'_tn','tn_'+i+'.jpg')
|
||||
inpath=os.path.join(path,i)
|
||||
if (not os.path.exists(outmedium)):
|
||||
print('Medium.. '+i+' '+str(n)+'/'+str(nsum))
|
||||
create_medium_bitmap(inpath,outmedium,r,vector=vectorsearch.match(i))
|
||||
if (not os.path.exists(outthumb)):
|
||||
print('Thumbnail.. '+i+' '+str(n)+'/'+str(nsum))
|
||||
create_thumb_bitmap(outmedium,outthumb,vector=vectorsearch.match(i))
|
||||
n+=1
|
||||
return
|
||||
|
||||
def create_medium_bitmap(infile,outfile,r,vector=False):
|
||||
res=r+'x'+r+'>'
|
||||
if vector:
|
||||
convargs=['convert','-density','300x300',infile+'[0]','-background','white','-flatten','-resize',res,'-quality','97',outfile]
|
||||
else:
|
||||
convargs=['convert','-define','jpeg:size='+r+'x'+r,infile+'[0]','-background','white','-flatten','-resize',res,'-quality','85',outfile]
|
||||
convp=subprocess.call(convargs)
|
||||
return
|
||||
|
||||
def create_thumb_bitmap(infile,outfile,vector=False):
|
||||
if vector:
|
||||
convargs=['convert','-density','300x300',infile,'-background','white','-flatten','-thumbnail','90x90^','-gravity','Center','-crop','90x90+0+0','+repage','-quality','75',outfile]
|
||||
else:
|
||||
convargs=['convert','-define','jpeg:size=300x300',infile,'-background','white','-flatten','-thumbnail','90x90^','-gravity','Center','-crop','90x90+0+0','+repage','-quality','75',outfile]
|
||||
convp=subprocess.call(convargs)
|
||||
return
|
||||
|
||||
def getdescriptions(path,list):
|
||||
''' Read descriptions.csv file and returns a list of descriptions.
|
||||
Missing descriptions are replaced with the file name. '''
|
||||
|
||||
Reference in New Issue
Block a user