1 If you use the rescaling feature of the directive [[ikiwiki/directive/img/]] with a smaller image it will distort. E.g. an image with 150x250 rescaled into size=200x200. --bastla
3 > More specifically: `img` normally preserves aspect ratio:
4 > `size=200x200` normally means "as large as possible, keeping
5 > the width 200px or less, the height 200px or less, and the
6 > aspect ratio correct". So a 4:3 image with `size=200x200`
7 > would actually come out 200px wide and 150px tall.
9 > However, when (desired width is specified) && (desired height is specified)
10 > && ((width > desired width) || (height > desired height)),
11 > it uses exactly the desired size, without preserving aspect ratio.
14 >> [[!template id=gitbranch branch=chrysn/imgforpdf-and-more author="[[chrysn]]"]]
18 >> i've implemented a fix for this along with a unit test.
20 >> the patch branch is based on the imgforpdf branch
21 >> ([[bugs/svg and pdf conversion fails]]), because it would not cleanly merge.
22 >> the branch also enhances on how images are handled in preview, falling back
23 >> to data: urls if the image has not been rendered in a saved version. please
24 >> review. --[[chrysn]]
26 >>> Mostly [[looks good to me|users/smcv/ready]].
28 >>> Minor things, which wouldn't stop me merging it if I could:
30 >>> * `$imgdatalink = "data:image/".$im->Get("magick").";base64,".encode_base64($blob[0]);`:
31 >>> is the ImageMagick file type always valid as the second part of
35 >>> +open (my $outhtmlfd, "<", "$outpath.html");
37 >>> +my $outhtml = <$outhtmlfd>;
38 >>> +close $outhtmlfd;
40 >>> no block is closed, so the "local" is ineffective, so the `<>` operator
41 >>> remains in read-entire-file mode afterwards. To avoid odd side-effects,
42 >>> I would suggest using `readfile()` like `t/trail.t` does.
44 >>> [[!template id=gitbranch branch=smcv/ready/imgforpdf-and-more author="[[chrysn]], [[smcv]]"
45 browse=http://git.pseudorandom.co.uk/smcv/ikiwiki.git/shortlog/refs/heads/ready/imgforpdf-and-more]]
46 >>> I've used `readfile()` (but not done anything about the ImageMagick file type)
47 >>> in my copy of the branch.
51 >>>> [[merged|done]] --[[smcv]]