prevent an unsigned overflow in FT1 has_chars() implementation
[imager.git] / design / tags.txt
CommitLineData
64d3e448
TC
1Currently when writing an animated gif you can do:
2
3 Imager->write_multi({ type=>'gif', file=>'foo.gif',
4 gif_delays => [ (10) x @images ] },
5 @images);
6
7and it will write out the images in @images with the given delay
8between each image.
9
10Now let's say we decide that all options are to be supplied in tags
11instead of as parameters, this includes things like the jpegquality
12(if possible) and tiff text tags.
13
14The problem with this is that we're making it harder to write the
15image, rather than supplying the parameters to write*() the user needs
16to go through an set tags:
17
18 $_->addtag(name=>'gif_delay', value=>10) for @images;
19 Imager->write_multi({ type=>'gif', file=>'foo.gif'},
20 @images);
21
22It's worse if the user needs to set more options:
23
24 $_->addtag(name=>'gif_delay', value=>10) for @images;
25 $_->addtag(name=>'gif_user_input', value=>1) for @images;
26 Imager->write_multi({ type=>'gif', file=>'foo.gif'},
27 @images);
28
29Now we could add a function to simplify this:
30
31 $_->addtags(gif_delay=>10, gif_user_input=>1) for @images;
32 Imager->write_multi({ type=>'gif', file=>'foo.gif'},
33 @images);
34
35but consider how we can preserve some of the existing interface.
36
37The option I was considering was to have the write*() methods set any
38parameters that have the file type as a prefix in the write call, as
39tags in the image, hence:
40
41 Imager->write_multi({ type=>'gif', file=>'foo.gif',
42 gif_delay => [ (10) x @images ],
43 gif_user_input => [ (1) x @images ] },
44 @images);
45
46If the value provided isn't an array reference, we could expand that to the number of images, so:
47
48 Imager->write_multi({ type=>'gif', file=>'foo.gif',
49 gif_delay => 10,
50 gif_user_input => 1 },
51 @images);
52
53This also applies nicely to TIFFs:
54
55 Imager->write_multi({ type=>'tiff', file=>'foo.tiff',
56 tiff_pagename => [ map "Page $_", 1 .. @images ],
57 tiff_documentname => "My New Document" },
58 @images);
59
60Now the names aren't going to be completely compatible between the old
61interface and the new, since the gif names at least tend to be
62plurals, but we do preserve the ease of use of the interface, making
63it more DWIM than a "set tags then write" interface.
64
65The main problem with this interface is we're modifying images that
66we're meant to be writing to a file, which really shouldn't require
67modifying the images.
68
69We discussed some of this in IRC a while ago, but didn't come to any
70decisions.