only crop top and bottom of pages
This commit is contained in:
parent
95430eea1b
commit
0d11e6ae5a
@ -135,6 +135,13 @@ def quantizeImage(image, palette):
|
|||||||
|
|
||||||
@protect_bad_image
|
@protect_bad_image
|
||||||
def scaleCropImage(image, size):
|
def scaleCropImage(image, size):
|
||||||
|
widthDev, heightDev = size
|
||||||
|
widthImg, heightImg = image.size
|
||||||
|
|
||||||
|
# don't crop 2 page spreads.
|
||||||
|
if (float(widthImg) / float(heightImg)) > (float(widthDev) / float(heightDev)):
|
||||||
|
return resizeImage(image, size)
|
||||||
|
|
||||||
return ImageOps.fit(image, size, Image.ANTIALIAS)
|
return ImageOps.fit(image, size, Image.ANTIALIAS)
|
||||||
|
|
||||||
|
|
||||||
@ -184,11 +191,12 @@ def orientImage(image, size):
|
|||||||
# by inverting colors, and asking a bounder box ^^
|
# by inverting colors, and asking a bounder box ^^
|
||||||
@protect_bad_image
|
@protect_bad_image
|
||||||
def autoCropImage(image):
|
def autoCropImage(image):
|
||||||
|
w, h = image.size
|
||||||
try:
|
try:
|
||||||
x0, y0, xend, yend = ImageChops.invert(image).getbbox()
|
x0, y0, xend, yend = ImageChops.invert(image).getbbox()
|
||||||
except TypeError: # bad image, specific to chops
|
except TypeError: # bad image, specific to chops
|
||||||
return image
|
return image
|
||||||
image = image.crop((x0, y0, xend, yend))
|
image = image.crop((0, y0, w, yend))
|
||||||
|
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="checkboxScaleCrop">
|
<widget class="QRadioButton" name="checkboxScaleCrop">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Scale and crop images to fill the screen</string>
|
<string>Scale and crop images to fill screen width</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user