]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/image_rescaling_distorts_with_small_pictures.mdwn
(no commit message)
[ikiwiki.git] / doc / bugs / image_rescaling_distorts_with_small_pictures.mdwn
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
2
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.
8 >
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.
12 > --smcv
13
14 >> [[!template id=gitbranch branch=chrysn/imgforpdf-and-more author="[[chrysn]]"]]
15 >>
16 >> [[!tag patch]]
17 >>
18 >> i've implemented a fix for this along with a unit test.
19 >>
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]]
25
26 >>> Mostly [[looks good to me|users/smcv/ready]].
27 >>>
28 >>> Minor things, which wouldn't stop me merging it if I could:
29 >>>
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
32 >>>   a MIME type?
33 >>> * In this code:
34 >>>
35 >>>       +open (my $outhtmlfd, "<", "$outpath.html");
36 >>>       +local $/=undef;
37 >>>       +my $outhtml = <$outhtmlfd>;
38 >>>       +close $outhtmlfd;
39 >>>
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.
43 >>>
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.
48 >>>
49 >>> --[[smcv]]
50
51 >>>> [[merged|done]] --[[smcv]]