mirror of
https://github.com/ciromattia/kcc
synced 2026-10-11 20:12:33 +00:00
Fixed stretching images smaller than device screen
This commit is contained in:
+8
-8
@@ -235,6 +235,14 @@ class ComicPage:
|
|||||||
size = (self.size[0], self.size[1])
|
size = (self.size[0], self.size[1])
|
||||||
else:
|
else:
|
||||||
size = (self.panelviewsize[0], self.panelviewsize[1])
|
size = (self.panelviewsize[0], self.panelviewsize[1])
|
||||||
|
# If stretching is on - Resize without other considerations
|
||||||
|
if stretch:
|
||||||
|
if self.image.size[0] <= size[0] and self.image.size[1] <= size[1]:
|
||||||
|
method = Image.BICUBIC
|
||||||
|
else:
|
||||||
|
method = Image.ANTIALIAS
|
||||||
|
self.image = self.image.resize(size, method)
|
||||||
|
return self.image
|
||||||
# If image is smaller than target resolution and upscale is off - Just expand it by adding margins
|
# If image is smaller than target resolution and upscale is off - Just expand it by adding margins
|
||||||
if self.image.size[0] <= size[0] and self.image.size[1] <= size[1] and not upscale:
|
if self.image.size[0] <= size[0] and self.image.size[1] <= size[1] and not upscale:
|
||||||
borderw = (size[0] - self.image.size[0]) / 2
|
borderw = (size[0] - self.image.size[0]) / 2
|
||||||
@@ -247,14 +255,6 @@ class ComicPage:
|
|||||||
if self.image.size[0] != size[0] or self.image.size[1] != size[1]:
|
if self.image.size[0] != size[0] or self.image.size[1] != size[1]:
|
||||||
self.image = ImageOps.fit(self.image, size, method=Image.BICUBIC, centering=(0.5, 0.5))
|
self.image = ImageOps.fit(self.image, size, method=Image.BICUBIC, centering=(0.5, 0.5))
|
||||||
return self.image
|
return self.image
|
||||||
# If stretching is on - Resize without other considerations
|
|
||||||
if stretch:
|
|
||||||
if self.image.size[0] <= size[0] and self.image.size[1] <= size[1]:
|
|
||||||
method = Image.BICUBIC
|
|
||||||
else:
|
|
||||||
method = Image.ANTIALIAS
|
|
||||||
self.image = self.image.resize(size, method)
|
|
||||||
return self.image
|
|
||||||
# Otherwise - Upscale/Downscale
|
# Otherwise - Upscale/Downscale
|
||||||
ratioDev = float(size[0]) / float(size[1])
|
ratioDev = float(size[0]) / float(size[1])
|
||||||
if (float(self.image.size[0]) / float(self.image.size[1])) < ratioDev:
|
if (float(self.image.size[0]) / float(self.image.size[1])) < ratioDev:
|
||||||
|
|||||||
Reference in New Issue
Block a user