Closed jamesharding closed 9 years ago
I faced the same issue recently on my own photo site during the transition to HiDPI images. As of v2.1.0, cropped images should be enlarged unless you pass enlarge=False
(see example from my site).
Let me know if the latest version is[n't] working for you.
On your site, that is in fit mode as opposed to the crop mode. With fit, the aspect ratio of the original image is unchanged, but I guess that what I am looking for is for image to be scaled up to have its shortest edges > the required size, and then for the crop to happen. In my case I want all outputs to be perfect squares), and for them to all be the exact size that is passed to the function.
I am using resized_img_src(user.photo_path, width=400, height=400, mode='fit', quality=95)
as my call.
If the pictures have both edges longer than 400px it works perfectly. If one edge is less than 400px, then the output image no longer has a square aspect ratio.
There is also this example, in which I am enlarging a crop because I too want perfect squares (or rectangles; here it is in action).
I could be wrong and mine working due to the HiDPI-ness. Can you confirm for me you are on v2.1.0, or the master from GitHub?
I am on the PIP version 2.1.1. With the version on your site, if you passed it an image that was smaller than the desired output, does is still correctly scale it up and maintain the output size/aspect ratio?
Here is what it looks like, with Tom's picture being 265x331 input, and the output is also 265x331.
I think it is actually an issue with caching. Stay tuned.
I think it was a caching issue (in which the enlarge parameter wasn't being taken into account when caching the results, so if you added enlarge=True
without changing anything else then it wouldn't even try to resize the image).
Please try the new master. I've also tried to document a few more parameters. ;)
Hmmm, it still seems to be an issue even with the latest master. Have you tried testing it on your site with an image that is smaller than the output resolution (and not of the same aspect ratio too)?
Yup. The demo works as expected too (the source is 240x160).
Brilliant, that has fixed it :) I needed to restart my gunicorn instance for it to load the new flask-images version.
Thank-you! This plugin is fantastic.
Awesome! You should see the problems I have when I keep introducing this same caching bug over and over...
I'll let it settle, and then release on the PyPI.
I have now released this on the PyPI as v2.1.2. =]
More of a feature request than an issue:
If an uploaded image is 200x400px, and in crop mode the desired output is 400px by 400px, would it be possible to allow the outputted image to be a zoomed/enlarged cropped image that is 400x400px and zoomed on the centre of the image? Right now, the output will never be larger than the original (and would output an image of the original 200x400 size in the above example).