]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/bugs/Colons___8216__:__8217___should_not_be_allowed_in_image_filenames.mdwn
img: stop ImageMagick trying to be clever if filenames contain a colon
[git.ikiwiki.info.git] / doc / bugs / Colons___8216__:__8217___should_not_be_allowed_in_image_filenames.mdwn
1 `IkiWiki::Plugin::img` appends `[$pagenumber]` to the filename to deal with multipage documents such as PDFs.
2 However, `Image::Magick` doesn't seem to like page selection for filenames containing a colon.  This is also the case for imagemagick binaries:
4     $ identify 'screenshot_2015-06-06_18:37:53.png'
5     screenshot_2015-06-06_18:37:53.png PNG 453x122 453x122+0+0 8-bit sRGB 11.2KB 0.000u 0:00.000
6     $ identify 'screenshot_2015-06-06_18:37:53.png[0]'
7     identify: no decode delegate for this image format `37' @ error/constitute.c/ReadImage/501.
8     $ mv 'screenshot_2015-06-06_18:37:53.png' 'screenshot_2015-06-06_18-37-53.png'
9     $ identify 'screenshot_2015-06-06_18-37-53.png[0]'
10     screenshot_2015-06-06_18-37-53.png[0]=>screenshot_2015-06-06_18-37-53.png PNG 453x122 453x122+0+0 8-bit sRGB 11.2KB 0.000u 0:00.000
12 This might be an imagemagick bug, but it's also possible that colons
13 are interpreted somehow.
15 > Yes they are: ImageMagick has syntax to force the file to be
16 > interpreted as a particular format, like gif:foobar.img to
17 > read foobar.img as a GIF, or to use unusual I/O patterns, like
18 > fd:5. --[[smcv]]
20 Anyway, to render such images properly in ikiwiki I had to remove
21 the colons.  An easy fix is to remove ‘:’ from `wiki_file_chars`,
22 but this can break existing installations.
24 > I think we should remove `:` from the default `wiki_file_chars`
25 > either as soon as we have a way to handle backwards compatibility,
26 > or in ikiwiki 4; but you're right that it's a compat problem,
27 > so we can't just do that as a solution. --s
29 A better solution would be to make `IkiWiki::Plugin::img` croak on
30 such image filenames (which anyway are currently not rendered, but
31 `Image::Magick`'s error message is quite cryptic).
33 > Better still would be to fix the bug by escaping the filename
34 > so ImageMagick treats it as just a filename. It seems the way
35 > to do that is to call `Read(":hello:world.png")` instead of
36 > `Read("hello:world.png")`, which I have now [[done]]. --s