View Single Post
Old 06-07-2019, 12:47 AM   #79
AlanHK
Guru
AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.
 
AlanHK's Avatar
 
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
Quote:
Originally Posted by DiapDealer View Post
It's not immediately clear that the image.thumbnail() function of Pillow is actually altering the original image, rather than returning a new, smaller copy of it.
I don't think so -- the images seem sharp as original. I've used it in several books and would feel compelled to redo the images if they are indeed downsampled and not just rescaled. The whole reason I used SVG is to get maximum size without distortion.

So I hope what it is doing now can be clarified: does it downsample to 400px?

PS-- did some tests. I made a PNG with 1 px lines 1 px apart, image size 800x800.

the SVG plugin made:

Code:
<div><svg 
	xmlns="http://www.w3.org/2000/svg"
	height="100%"  width="100%"
	preserveAspectRatio="xMidYMid meet" version="1.1"
	viewBox="0 0 400 400"
	xmlns:xlink="http://www.w3.org/1999/xlink">
	<image width="400" height="400" xlink:href="../Images/bigtest.png"/>
	</svg> </div>
I copied this file and made it:

Code:
<div><svg 
	xmlns="http://www.w3.org/2000/svg"
	height="100%"  width="100%"
	preserveAspectRatio="xMidYMid meet" version="1.1"
	viewBox="0 0 800 800"
	xmlns:xlink="http://www.w3.org/1999/xlink">
	<image width="800" height="800" xlink:href="../Images/bigtest.png"/>
	</svg></div>
Comparing them on screen, see two lines in both.
If I resize the PNG in PhotoShop to 400x400, the lines blur into each other, as the gap becomes 0.5 px.

So, the plugin isn't resampling. It's silly, but not degrading the image.

PPS--

Took it the other way and made the "thumbnail" size even smaller.
All looked fine, even down to:

Code:
<div><svg 
	xmlns="http://www.w3.org/2000/svg"
	height="100%" width="100%" 
	preserveAspectRatio="xMidYMid meet" version="1.1" 
	viewBox="0 0 1 1" 
	xmlns:xlink="http://www.w3.org/1999/xlink">
	<image width="1" height="1" xlink:href="../Images/bigtest.png"/>
	</svg></div>
It might however distort the image slightly as the aspect ratio becomes less precise with smaller numbers.

Last edited by AlanHK; 06-07-2019 at 04:22 AM.
AlanHK is offline   Reply With Quote