Added thumbnail cropping gravity
This commit is contained in:
@@ -53,6 +53,8 @@ folder is the root folder of the image album (defaults to current folder).'''
|
||||
help="Recurse in to subfolders")
|
||||
parser.add_argument("-w",type=int,dest="width",default=850,
|
||||
help="Medium image size (Default: %(default)s)")
|
||||
parser.add_argument("--gravity",type=str,dest="gravity",default="Center",
|
||||
help="ImageMagick gravity for cropping. (Default: %(default)s)")
|
||||
parser.add_argument("startpath",type=str,action="store",default=os.path.abspath('.'),nargs='?',
|
||||
help="Start path for recursion")
|
||||
options=parser.parse_args()
|
||||
|
||||
12
Qalbum.py
12
Qalbum.py
@@ -268,7 +268,7 @@ def createthumbs(path,list,options):
|
||||
create_medium_bitmap(inpath,outmedium,r,link=options.link,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))
|
||||
create_thumb_bitmap(outmedium,outthumb,vector=vectorsearch.match(i),gravity=options.gravity)
|
||||
n+=1
|
||||
return
|
||||
|
||||
@@ -284,11 +284,11 @@ def create_medium_bitmap(infile,outfile,r,link=False,vector=False):
|
||||
convp=subprocess.call(convargs)
|
||||
return
|
||||
|
||||
def create_thumb_bitmap(infile,outfile,vector=False):
|
||||
def create_thumb_bitmap(infile,outfile,vector=False,gravity='Center'):
|
||||
if vector:
|
||||
convargs=['convert','-density','300x300',infile,'-background','white','-flatten','-thumbnail','90x90^','-gravity','Center','-crop','90x90+0+0','+repage','-quality','75',outfile]
|
||||
convargs=['convert','-density','300x300',infile,'-background','white','-flatten','-thumbnail','90x90^','-gravity',gravity,'-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]
|
||||
convargs=['convert','-define','jpeg:size=300x300',infile,'-background','white','-flatten','-thumbnail','90x90^','-gravity',gravity,'-crop','90x90+0+0','+repage','-quality','75',outfile]
|
||||
convp=subprocess.call(convargs)
|
||||
return
|
||||
|
||||
@@ -444,6 +444,8 @@ def setupoptions():
|
||||
help="File name for info files in all folders. (Default: %(default)s)")
|
||||
parser.add_argument("-g",type=str,dest="gallery",default="Gallery",
|
||||
help="Name for the root gallery (Default: %(default)s)")
|
||||
parser.add_argument("--gravity",type=str,dest="gravity",default="Center",
|
||||
help="ImageMagick gravity for cropping. (Default: %(default)s)")
|
||||
parser.add_argument("-w",type=int,dest="width",default=850,
|
||||
help="Medium image size (Default: %(default)s)")
|
||||
parser.add_argument("-p",type=str,dest="parent",
|
||||
@@ -467,6 +469,8 @@ def setupdefaultoptions(options):
|
||||
options.infofile="info.txt"
|
||||
if 'gallery' not in options:
|
||||
options.gallery="Gallery"
|
||||
if 'gravity' not in options:
|
||||
options.gravity="Center"
|
||||
if 'link' not in options:
|
||||
options.link=False
|
||||
if 'recursive' not in options:
|
||||
|
||||
Reference in New Issue
Block a user